*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg:       #0b1622;
  --bg2:      #111e2e;
  --bg3:      #182638;
  --surface:  #1f3249;
  --border:   #243d5c;
  --border2:  #2d4f70;
  --accent:   #3d8ef0;
  --accent-d: #2272d9;
  --accent-g: rgba(61,142,240,0.12);
  --text:     #ddeeff;
  --text2:    #7fa0c0;
  --text3:    #4a6a85;
  --success:  #34d399;
  --error:    #f87171;
  --warning:  #fbbf24;
  --nav-h:    60px;
  --safe-b:   env(safe-area-inset-bottom, 0px);
  --safe-t:   env(safe-area-inset-top, 0px);
  --radius:   14px;
  --radius-s: 10px;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app { height: 100%; }

/* ── Loading ─────────────────────────────── */
.screen-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 20px;
}

.spinner {
  width: 36px; height: 36px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
  opacity: 0.7;
}

/* ── Auth screens ────────────────────────── */
.screen-auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 20px;
  overflow-y: auto;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
}

.brand-lockup {
  text-align: center;
  margin-bottom: 36px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px; height: 52px;
  background: var(--accent-g);
  border: 1px solid rgba(61,142,240,0.3);
  border-radius: 14px;
  margin-bottom: 12px;
}

.brand-logo svg { width: 28px; height: 28px; }

.brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
}

.brand-name span { color: var(--accent); }

.brand-tagline {
  font-size: 13px;
  color: var(--text3);
  margin-top: 3px;
}

.auth-heading {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.auth-sub {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 28px;
  line-height: 1.5;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--text3); }

.field input.code-input {
  font-family: 'DM Mono', monospace;
  font-size: 20px;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-s);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  gap: 8px;
}

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; margin-top: 8px; }
.btn-primary:hover:not(:disabled) { background: var(--accent-d); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}

.auth-footer {
  text-align: center;
  margin-top: 22px;
  font-size: 14px;
  color: var(--text2);
}

.auth-footer a {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.msg {
  padding: 11px 14px;
  border-radius: var(--radius-s);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
  display: none;
}

.msg.show { display: block; }
.msg-error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.25); color: #fca5a5; }
.msg-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.25); color: #6ee7b7; }

.invite-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.invite-icon-wrap .icon-circle {
  width: 64px; height: 64px;
  background: var(--accent-g);
  border: 1px solid rgba(61,142,240,0.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ── App shell ───────────────────────────── */
.screen-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  padding-top: calc(14px + var(--safe-t));
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-brand { display: flex; align-items: center; gap: 10px; }

.header-logo {
  width: 34px; height: 34px;
  background: var(--accent-g);
  border: 1px solid rgba(61,142,240,0.3);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}

.header-logo svg { width: 18px; height: 18px; }

.header-text-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.header-text-name span { color: var(--accent); }

.header-org {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
  font-weight: 500;
}

.icon-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px;
  cursor: pointer;
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}

.icon-btn:hover { color: var(--text); border-color: var(--border2); }

/* ── Content area ────────────────────────── */
.app-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.section {
  display: none;
  padding: 20px;
  padding-bottom: calc(var(--nav-h) + 20px + var(--safe-b));
  animation: fadeIn 0.18s ease;
}

.section.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head { margin-bottom: 22px; }
.section-title { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.section-subtitle { font-size: 14px; color: var(--text2); margin-top: 4px; }

/* ── Cards ───────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}

.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.card-body { font-size: 14px; color: var(--text2); line-height: 1.6; }
.card-meta { font-size: 12px; color: var(--text3); margin-top: 10px; display: flex; align-items: center; gap: 6px; }

/* ── Badge ───────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.badge-blue { background: rgba(61,142,240,0.15); color: #60a5fa; }
.badge-green { background: rgba(52,211,153,0.15); color: #34d399; }
.badge-amber { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-gray { background: rgba(74,106,133,0.2); color: var(--text2); }

/* ── Empty state ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 52px 20px;
}

.empty-icon {
  width: 52px; height: 52px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  color: var(--text3);
}

.empty-icon svg { width: 22px; height: 22px; }

.empty-state h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  max-width: 260px;
  margin: 0 auto;
}

/* ── Coming soon banner ──────────────────── */
.coming-soon {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-s);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text2);
}

.coming-soon svg { flex-shrink: 0; color: var(--accent); width: 16px; height: 16px; }

/* ── Bottom nav ──────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text3);
  transition: color 0.15s;
  border: none;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.nav-item.active { color: var(--accent); }

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-label { font-size: 10px; font-weight: 600; }

/* ── Member row ──────────────────────────── */
.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.member-row:last-child { border-bottom: none; }

.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 15px; font-weight: 600; }
.member-email { font-size: 12px; color: var(--text2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Divider ─────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 4px 0 16px; }

.hidden { display: none !important; }
