﻿:root {
  --bg-0: #070b09;
  --bg-1: #0c1310;
  --bg-2: #111b16;
  --surface-0: #111915;
  --surface-1: #16231c;
  --surface-2: #1b2c22;
  --surface-3: #23372a;
  --text: #ecf2ee;
  --text-2: #cdd9d1;
  --muted: #94aa9e;
  --line: rgba(126, 156, 136, 0.28);
  --line-strong: rgba(143, 183, 157, 0.48);
  --accent: #6fbf4a;
  --accent-2: #4d9f2e;
  --accent-cyan: #4db8a8;
  --danger: #d44d4d;
  --warning: #d2a349;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.34);
  --shadow-mid: 0 20px 46px rgba(0, 0, 0, 0.44);
  --glow: 0 0 0 1px rgba(111, 191, 74, 0.26), 0 0 24px rgba(111, 191, 74, 0.2);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  color: var(--text);
  font-family: "Rajdhani", "Segoe UI", "SF Pro Text", -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1200px 900px at 15% -15%, rgba(111, 191, 74, 0.14), transparent 58%),
    radial-gradient(900px 760px at 90% 120%, rgba(77, 184, 168, 0.12), transparent 62%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1) 48%, var(--bg-2));
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(transparent 95%, rgba(170, 205, 184, 0.05) 96%),
    linear-gradient(90deg, transparent 95%, rgba(170, 205, 184, 0.04) 96%);
  background-size: 28px 28px;
  opacity: 0.28;
}

body::after {
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.04), transparent 42%);
}

a,
button,
input,
select,
textarea,
label {
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea {
  border-radius: 12px;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(21, 32, 25, 0.96), rgba(17, 26, 21, 0.96));
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #7f968a;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

#app { min-height: 100vh; }

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 24px 14px 110px;
  padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}

.screen { display: none; }
.screen.active {
  display: block;
  animation: screenIn 220ms ease;
}

#login-screen.active {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 48px);
}

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

.card {
  background: linear-gradient(155deg, rgba(24, 37, 30, 0.94), rgba(16, 25, 21, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.auth-card {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 34px 26px;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-mid);
  border-color: var(--line-strong);
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 3rem);
  letter-spacing: 0.08em;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-card p { margin: 8px 0 0; color: var(--muted); }

.pin-dots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(157, 190, 171, 0.42);
  background: #101813;
  margin: 0 auto;
}

.dot.filled {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(111, 191, 74, 0.24);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.pin-key,
.ghost-btn,
.primary-btn,
.danger-btn,
.nav-btn,
.conversation-item {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  max-width: 100%;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 160ms ease, filter 130ms ease, border-color 160ms ease;
}

.pin-key {
  min-height: 58px;
  background: linear-gradient(180deg, #2b4736, #1f3328);
  border-color: #4f7b61;
  color: #f2f8f4;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 10px 18px rgba(0,0,0,0.28);
}

.pin-key:hover {
  filter: brightness(1.06);
  border-color: #8dccaa;
}

.pin-key:active,
.primary-btn:active,
.ghost-btn:active,
.nav-btn:active,
.conversation-item:active { transform: scale(0.98); }

.message {
  min-height: 20px;
  margin-top: 12px;
  color: #ff9f9f;
  font-weight: 600;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(140deg, rgba(28, 42, 34, 0.92), rgba(19, 30, 24, 0.94));
  box-shadow: var(--shadow-soft);
}

.topbar h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3.5vw, 1.7rem);
}

.topbar p { margin: 3px 0 0; color: var(--muted); }

.ghost-btn {
  background: linear-gradient(180deg, #223429, #1b2a20);
  border-color: #355340;
  color: var(--text-2);
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: #89d66b;
  color: #0d140f;
  padding: 0 14px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(60, 120, 35, 0.4);
}

.danger-btn {
  background: linear-gradient(180deg, #6e2e2e, #562323);
  border-color: #b65f5f;
  color: #ffe4e4;
  padding: 0 14px;
  font-weight: 700;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.view { display: none; }
.view.active { display: block; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 14px;
  background: linear-gradient(180deg, rgba(30, 46, 36, 0.95), rgba(23, 35, 29, 0.96));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 20px rgba(0, 0, 0, 0.3);
}

.stat h3 {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat p {
  margin: 8px 0 0;
  font-size: 1.07rem;
  font-weight: 760;
}

.stat .primary-btn {
  margin-top: 10px;
  width: 100%;
}

.list-card {
  margin-top: 12px;
  padding: 14px;
}

.list-card h3 {
  margin: 0 0 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 1rem;
}

.program-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(28, 43, 34, 0.9), rgba(21, 33, 27, 0.92));
  margin-bottom: 8px;
}

.program-item:last-child { margin-bottom: 0; }
.program-title { margin: 0; font-size: 1.02rem; }
.program-text { margin: 0; color: var(--text-2); }

.program-check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.program-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.event {
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(30, 45, 37, 0.92), rgba(22, 35, 28, 0.94));
}

.event h4 {
  margin: 0 0 8px;
  font-size: 1.02rem;
}

.event p {
  margin: 4px 0;
  color: var(--text-2);
}

.form-grid {
  display: grid;
  gap: 10px;
}

.group-form { margin-top: 10px; }

.group-members {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.group-member-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(27, 40, 33, 0.82);
}

.group-member-item input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.chat-shell { overflow: hidden; }

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-head h3,
.chat-head p {
  margin: 0;
}

.chat-head p { color: var(--muted); }

.chat-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 10px;
  min-height: 62dvh;
}

.chat-sidebar,
.chat-main {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(24, 37, 30, 0.9), rgba(19, 28, 23, 0.95));
  padding: 10px;
}

.conversation-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  max-height: 48dvh;
  overflow: auto;
  padding-right: 2px;
}

.conversation-item {
  width: 100%;
  text-align: left;
  padding: 10px;
  border-color: var(--line);
  background: linear-gradient(180deg, rgba(30, 46, 37, 0.9), rgba(23, 34, 28, 0.95));
  color: var(--text);
}

.conversation-item.active {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.conversation-item-title {
  display: block;
  font-weight: 750;
}

.conversation-item-last {
  display: block;
  color: var(--muted);
  margin-top: 2px;
  font-size: 0.92rem;
}

.chat-main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}

.chat-main-head h4 {
  margin: 0;
}

.chat-thread {
  min-height: 30dvh;
  max-height: 50dvh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(18, 27, 22, 0.95), rgba(13, 20, 17, 0.98));
}

.chat-empty {
  color: var(--muted);
  margin: 0;
}

.msg-bubble {
  max-width: min(85%, 700px);
  margin-bottom: 10px;
  border-radius: 13px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  word-break: break-word;
}

.msg-bubble.other {
  margin-right: auto;
  background: linear-gradient(180deg, rgba(36, 54, 43, 0.95), rgba(27, 41, 33, 0.96));
}

.msg-bubble.mine {
  margin-left: auto;
  background: linear-gradient(180deg, rgba(96, 140, 70, 0.28), rgba(61, 97, 43, 0.3));
  border-color: rgba(132, 202, 98, 0.56);
}

.msg-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 5px;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chat-compose .primary-btn {
  min-width: 92px;
}

.admin-split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(1240px, calc(100vw - 20px));
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  margin-top: 0;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(20, 31, 25, 0.98), rgba(14, 22, 18, 0.98));
  border-radius: 14px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.06);
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  z-index: 60;
}

.nav-btn {
  min-width: 0;
  width: 100%;
  padding: 10px 6px;
  border-color: transparent;
  color: var(--text-2);
  background: transparent;
  font-weight: 730;
  font-size: clamp(0.74rem, 2.6vw, 0.95rem);
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.nav-btn.active {
  background: linear-gradient(180deg, rgba(111, 191, 74, 0.96), rgba(82, 154, 48, 0.96));
  border-color: rgba(173, 226, 145, 0.58);
  color: #0a120c;
  box-shadow: 0 8px 16px rgba(78, 133, 52, 0.46);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(130, 166, 145, 0.32);
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: rgba(12, 18, 15, 0.42);
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-split { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .app-shell { padding: 18px 10px 106px; }
  .topbar { padding: 12px; }
  .chat-layout { grid-template-columns: 1fr; min-height: auto; }
  .chat-sidebar { order: 1; }
  .chat-main { order: 2; }
  .conversation-list { max-height: 30dvh; }
  .chat-thread { max-height: 42dvh; }
  .admin-split { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  #login-screen.active { min-height: calc(100dvh - 24px); }

  .auth-card {
    margin-top: 0;
    padding: 22px 16px;
  }

  .stats { grid-template-columns: 1fr; }

  .bottom-nav {
    width: calc(100vw - 12px);
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }


  .nav-btn {
    min-height: 48px;
    font-size: clamp(0.7rem, 2.9vw, 0.85rem);
    letter-spacing: 0.01em;
  }

  .msg-bubble { max-width: 92%; }
}
