/* MSS Member Portal CSS — Mobile First */
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,400&display=swap');

:root {
  --c1: #1a6b3c; --c1d: #0d4a28; --c1l: #2d8a55;
  --c2: #f0a500; --c2d: #cc8800;
  --bg: #eef6f0; --surface: #fff;
  --t1: #111827; --t2: #374151; --t3: #6b7280;
  --border: #e5e7eb; --r: 14px;
  --approved: #15803d; --pending: #d97706; --rejected: #dc2626;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body { font-family: 'Poppins', sans-serif; background: var(--bg); color: var(--t1); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }
button { font-family: 'Poppins', sans-serif; }
img { max-width: 100%; }

/* ── App container ── */
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; overflow-x: hidden; background: var(--bg); }

/* ── Hero ── */
.hero { background: linear-gradient(160deg, var(--c1d) 0%, var(--c1) 55%, var(--c1l) 100%); padding: 48px 22px 90px; text-align: center; position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%; background: rgba(255,255,255,.04); top: -80px; right: -80px; }
.hero::after  { content: ''; position: absolute; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.04); bottom: -60px; left: -60px; }
.hero-logo-wrap { margin: 0 auto 16px; width: 80px; height: 80px; border-radius: 50%; overflow: hidden; border: 3px solid rgba(255,255,255,.35); background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; }
.hero-logo-wrap img { width: 100%; height: 100%; object-fit: cover; }
.hero-logo-ph { font-size: 32px; font-weight: 900; color: #fff; }
.hero-title   { color: #fff; font-size: 24px; font-weight: 800; line-height: 1.2; }
.hero-en      { color: var(--c2); font-size: 18px; font-weight: 700; margin-top: 2px; }
.hero-sub     { color: rgba(255,255,255,.7); font-size: 13px; margin-top: 6px; }
.hero-pill    { display: inline-flex; align-items: center; gap: 6px; background: rgba(240,165,0,.2); border: 1px solid rgba(240,165,0,.45); color: var(--c2); padding: 5px 14px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .5px; margin-top: 14px; }
.hero-sm      { padding: 28px 22px 68px; }
.hero-back    { position: absolute; left: 16px; top: 18px; width: 38px; height: 38px; background: rgba(255,255,255,.15); border: none; border-radius: 50%; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; }

/* ── Sheet ── */
.sheet { background: var(--surface); border-radius: 28px 28px 0 0; margin-top: -28px; padding: 28px 20px 100px; min-height: 60vh; }

/* ── Stats row ── */
.stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 28px; }
.stat-card  { background: linear-gradient(135deg,#f0f7f2,#e8f5ed); border-radius: 12px; padding: 14px 8px; text-align: center; border: 1px solid #d1eadc; }
.stat-n     { font-size: 22px; font-weight: 800; color: var(--c1); }
.stat-l     { font-size: 10px; color: var(--t3); font-weight: 600; margin-top: 2px; text-transform: uppercase; }

/* ── Forms ── */
.form-head h2 { font-size: 20px; font-weight: 700; color: var(--t1); }
.form-head p  { font-size: 13px; color: var(--t3); margin-top: 3px; margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--t2); margin-bottom: 5px; }
.req  { color: var(--rejected); }
.inp-wrap { position: relative; }
.inp-ico  { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--t3); font-size: 14px; pointer-events: none; }
.inp  { width: 100%; padding: 13px 14px 13px 40px; border: 2px solid var(--border); border-radius: var(--r); font-family: 'Poppins',sans-serif; font-size: 14px; background: #fafafa; color: var(--t1); transition: border .2s, box-shadow .2s; }
.inp:focus { outline: none; border-color: var(--c1); background: #fff; box-shadow: 0 0 0 4px rgba(26,107,60,.08); }
.inp-plain { padding-left: 14px; }
.eye-btn { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--t3); cursor: pointer; font-size: 14px; padding: 4px; }
textarea.inp { resize: vertical; min-height: 80px; padding-top: 12px; }
select.inp { cursor: pointer; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 20px; border: none; border-radius: var(--r); font-family: 'Poppins',sans-serif; font-size: 14px; font-weight: 700; cursor: pointer; transition: all .2s; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--c1), var(--c1d)); color: #fff; box-shadow: 0 4px 16px rgba(26,107,60,.35); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(26,107,60,.45); }
.btn-accent  { background: linear-gradient(135deg, var(--c2), var(--c2d)); color: #fff; }
.btn-ghost   { background: #f1f5f9; color: var(--t2); border: 1.5px solid var(--border); }
.btn-wa      { background: linear-gradient(135deg, #25d366, #1da851); color: #fff; }
.btn-full    { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* ── Divider ── */
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--t3); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Alerts ── */
.alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; line-height: 1.5; display: flex; align-items: flex-start; gap: 8px; }
.alert-err  { background: #fef2f2; border: 1px solid #fca5a5; color: var(--rejected); }
.alert-ok   { background: #f0fdf4; border: 1px solid #86efac; color: var(--approved); }
.alert-warn { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── Toast ── */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); padding: 10px 22px; border-radius: 24px; font-family: 'Poppins',sans-serif; font-size: 13px; font-weight: 600; z-index: 9800; white-space: nowrap; box-shadow: 0 4px 20px rgba(0,0,0,.2); pointer-events: none; animation: toastIn .3s ease, toastOut .3s ease 1.9s forwards; max-width: 90vw; }
.toast-ok   { background: var(--c1); color: #fff; }
.toast-err  { background: var(--rejected); color: #fff; }
.toast-info { background: #2563eb; color: #fff; }
@keyframes toastIn  { from { opacity:0; transform:translateX(-50%) translateY(10px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
@keyframes toastOut { to { opacity:0; } }

/* ── Spinner ── */
.spinner { width: 22px; height: 22px; border: 2.5px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner-green { border-color: rgba(26,107,60,.2); border-top-color: var(--c1); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Photo picker ── */
.photo-box { width: 120px; height: 140px; border-radius: var(--r); background: #f0f7f2; border: 2.5px dashed var(--c1l); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; overflow: hidden; margin: 0 auto 8px; transition: background .2s; }
.photo-box:hover { background: #e8f5ed; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-box-ico { font-size: 28px; color: var(--c1); }
.photo-box-lbl { font-size: 11px; color: var(--t3); font-weight: 600; text-align: center; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-approved { background: #dcfce7; color: var(--approved); }
.badge-pending  { background: #fef9ec; color: var(--pending); }
.badge-rejected { background: #fee2e2; color: var(--rejected); }

/* ── Bottom nav ── */
.bnav { display: flex; background: var(--surface); box-shadow: 0 -2px 12px rgba(0,0,0,.08); position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 200; }
.bnav-item { flex: 1; padding: 10px 4px 8px; border: none; background: none; font-family: 'Poppins',sans-serif; font-size: 10px; font-weight: 600; color: var(--t3); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; transition: color .2s; }
.bnav-item i { font-size: 18px; }
.bnav-item.active { color: var(--c1); }
.bnav-item.active i { font-size: 20px; }

/* ── Portal ── */
.portal-wrap { padding-bottom: 80px; }
.portal-hero { background: linear-gradient(160deg, var(--c1d), var(--c1) 60%, var(--c1l) 100%); padding: 22px 20px 70px; }
.portal-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.portal-avatar { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.35); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: #fff; flex-shrink: 0; }
.portal-avatar img { width: 100%; height: 100%; object-fit: cover; }
.logout-btn-sm { background: rgba(255,255,255,.15); border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.tab-content { padding: 16px; }
.welcome-card { background: linear-gradient(135deg, var(--c1), var(--c1d)); border-radius: 18px; padding: 20px; color: #fff; margin-bottom: 16px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info-item { background: var(--surface); border-radius: 12px; padding: 14px 12px; border: 1px solid var(--border); }
.info-label { font-size: 10px; color: var(--t3); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.info-val   { font-size: 13px; font-weight: 700; color: var(--t1); word-break: break-word; }
.settings-block { background: var(--surface); border-radius: 16px; padding: 20px; border: 1px solid var(--border); margin-bottom: 16px; }
.settings-block h3 { font-size: 15px; font-weight: 700; color: var(--t1); margin-bottom: 16px; }
.notice-card { background: var(--surface); border-radius: 14px; padding: 16px; border: 1px solid var(--border); margin-bottom: 12px; }
.notice-ts { font-size: 11px; color: var(--t3); margin-bottom: 5px; }
.notice-body { font-size: 13px; color: var(--t2); line-height: 1.65; }
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 180px); background: var(--surface); margin: -16px; }
.chat-teams { display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-teams::-webkit-scrollbar { display: none; }
.chat-team-btn { padding: 7px 16px; border: 2px solid var(--border); border-radius: 20px; background: var(--surface); font-family: 'Poppins',sans-serif; font-size: 12px; font-weight: 600; color: var(--t2); cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.chat-team-btn.active { background: var(--c1); color: #fff; border-color: var(--c1); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; background: var(--bg); }
.chat-input-bar { display: flex; gap: 8px; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-inp { flex: 1; padding: 11px 14px; border: 2px solid var(--border); border-radius: 24px; font-family: 'Poppins',sans-serif; font-size: 14px; }
.chat-inp:focus { outline: none; border-color: var(--c1); }
.chat-send { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--c1), var(--c1d)); color: #fff; border: none; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-end; }
.msg-mine { flex-direction: row-reverse; }
.msg-av { width: 32px; height: 32px; border-radius: 50%; background: var(--c1); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.msg-av img { width: 100%; height: 100%; object-fit: cover; }
.msg-bubble { max-width: 72%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.55; }
.msg:not(.msg-mine) .msg-bubble { background: var(--surface); border-radius: 4px 16px 16px 16px; border: 1px solid var(--border); }
.msg-mine  .msg-bubble { background: linear-gradient(135deg, var(--c1), var(--c1d)); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg-admin .msg-bubble { background: linear-gradient(135deg,#7c3aed,#4f46e5); color: #fff; border-radius: 4px 16px 16px 16px; }
.msg-name { font-size: 11px; font-weight: 700; color: var(--c1); margin-bottom: 3px; }
.msg-time { font-size: 10px; opacity: .6; margin-top: 4px; text-align: right; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--t3); }
.empty-state i { font-size: 40px; margin-bottom: 14px; display: block; opacity: .4; }
.empty-state h4 { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--t2); }
.empty-state p  { font-size: 13px; }


/* ══════════════════════════════════════════════════════════════
   MODERN UI/UX POLISH LAYER — animations, transitions, responsive
   (Additive only — does not alter any existing rule above)
═══════════════════════════════════════════════════════════════ */

/* ── Motion tokens ── */
:root {
  --ease: cubic-bezier(.16,1,.3,1);
  --shadow-sm: 0 2px 8px rgba(17,24,39,.06);
  --shadow-md: 0 8px 24px rgba(17,24,39,.10);
  --shadow-lg: 0 20px 50px rgba(17,24,39,.16);
}

/* ── Keyframes ── */
@keyframes fadeInUp   { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
@keyframes scaleIn    { from { opacity:0; transform:scale(.94); } to { opacity:1; transform:scale(1); } }
@keyframes shimmer    { 0% { background-position:-200% 0; } 100% { background-position:200% 0; } }
@keyframes softPulse  { 0%,100% { box-shadow:0 0 0 0 rgba(26,107,60,.25); } 50% { box-shadow:0 0 0 8px rgba(26,107,60,0); } }
@keyframes floatSlow  { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-6px); } }

/* ── Entrance animations (retrigger naturally since JS re-renders innerHTML) ── */
.hero        { animation: fadeInUp .5s var(--ease) both; }
.sheet       { animation: fadeInUp .45s var(--ease) .05s both; }
.stats-row   { animation: fadeInUp .4s var(--ease) .1s both; }
.stat-card   { transition: transform .22s var(--ease), box-shadow .22s var(--ease); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.form-head   { animation: fadeInUp .4s var(--ease) both; }
.field       { animation: fadeInUp .35s var(--ease) both; }

/* ── Buttons — smooth micro-interactions ── */
.btn, button { transition: transform .16s var(--ease), box-shadow .2s var(--ease), filter .2s var(--ease), background .2s var(--ease); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); filter: brightness(1.04); }
.btn-ghost:hover:not(:disabled)   { background: #f0f7f2; border-color: var(--c1l); }
.btn-full:active:not(:disabled)  { transform: scale(.985); }

/* ── Inputs — smoother focus glow ── */
.inp { transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease); }
.field label { transition: color .2s var(--ease); }
.field:focus-within label { color: var(--c1); }

/* ── Cards / list items — gentle lift on hover ── */
.stat-card, .notice-card, .chat-bubble, .member-row-card {
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}

/* ── Toast — softer entrance/exit, subtle blur backdrop ── */
.toast { backdrop-filter: blur(4px); }

/* ── Loading skeleton shimmer (use class="skeleton" on placeholder blocks) ── */
.skeleton {
  background: linear-gradient(90deg, #eef1ee 25%, #f6f8f6 37%, #eef1ee 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}

/* ── Spinner refinement ── */
.spinner { animation: spin .65s cubic-bezier(.5,0,.5,1) infinite; }

/* ── Focus-visible accessibility ring (keyboard nav) ── */
a:focus-visible, button:focus-visible, .inp:focus-visible {
  outline: 2px solid var(--c1l);
  outline-offset: 2px;
}

/* ── Custom scrollbar (webkit) ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(26,107,60,.25); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(26,107,60,.4); }

/* ── Respect reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — tablet & desktop polish
   (Mobile-first #app stays untouched below 640px)
═══════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  body { background: linear-gradient(160deg, #eef6f0 0%, #e3f0e8 100%); }
  #app {
    max-width: 460px;
    margin: 28px auto;
    min-height: calc(100vh - 56px);
    border-radius: 26px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: scaleIn .4s var(--ease) both;
  }
}

@media (min-width: 900px) {
  #app { max-width: 480px; margin: 40px auto; }
}
