:root {
  /* Exact HOOP website palette — hopeofoverseas.com */
  --green-deep: #015b27;
  --green-mid: #027146;
  --green-bright: #1d8b4c;
  --teal: #13a79b;
  --gold: #ffc61a;
  --gold-accent: #ecb538;
  --gold-dark: #d58d1e;
  --gold-light: #ffd64f;
  --gold-pale: #ffeb86;
  --gold-mid: #edb308;
  --ink: #363636;
  --ink-muted: #5a6b63;
  --line: #d0e0d8;
  --surface: #ffffff;
  --bg: #f3f8f5;
  --danger: #ff253a;
  --danger-bg: #fff1f2;
  --radius: 12px;
  --radius-pill: 50px;
  --shadow: 0 10px 15px rgba(0, 0, 0, 0.12);
  --font: "Open Sans", sans-serif;
  --heading: "Montserrat", sans-serif;
  --nav-gradient: linear-gradient(0deg, #015b27, #1d8b4c);
  --gold-gradient: linear-gradient(0deg, #d58d1e, #ffd64f);
  --topbar-gradient: linear-gradient(#ffeb86, #edb308);
  --section-gradient: linear-gradient(#13a79b, #027146);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(255, 198, 26, 0.14), transparent 50%),
    radial-gradient(ellipse 55% 40% at 0% 100%, rgba(19, 167, 155, 0.12), transparent 45%),
    linear-gradient(160deg, #e8f4ef 0%, var(--bg) 50%, #e6f0eb 100%);
  background-attachment: fixed;
}

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

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width, 260px) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  transition: grid-template-columns 0.28s ease;
  --sidebar-width: 260px;
}

.app.sidebar-collapsed {
  --sidebar-width: 84px;
}

.sidebar-overlay {
  display: none;
}

.app[hidden],
.login-screen[hidden] {
  display: none !important;
}

/* Login screen */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(255, 198, 26, 0.18), transparent 55%),
    linear-gradient(160deg, var(--green-deep) 0%, var(--green-mid) 45%, var(--teal) 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.login-logo {
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 8px 20px rgba(1, 91, 39, 0.2);
}

.login-title {
  margin: 0;
  font-family: var(--heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green-deep);
  line-height: 1.3;
}

.login-subtitle {
  margin: 0.4rem 0 1.5rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.login-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.login-form .field label {
  text-align: left;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
  justify-content: center;
}

.login-hint {
  margin: 1.15rem 0 0;
  padding: 0.75rem 0.9rem;
  background: rgba(19, 167, 155, 0.1);
  border: 1px dashed rgba(1, 91, 39, 0.25);
  border-radius: 10px;
  color: var(--ink-muted);
  font-size: 0.85rem;
  line-height: 1.55;
  text-align: left;
}

.login-hint strong {
  color: var(--green-deep);
  font-family: var(--heading);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.btn-logout {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 0.65rem 1rem;
  font-family: var(--heading);
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-logout:hover {
  background: rgba(255, 37, 58, 0.25);
  border-color: rgba(255, 37, 58, 0.5);
}

.btn-logout .logout-icon {
  width: 20px;
  height: 20px;
}

/* Sidebar — matches site deep green header #015b27 */
.sidebar {
  background: var(--green-deep);
  color: #ffffff;
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(1, 91, 39, 0.25);
  z-index: 60;
  transition: padding 0.28s ease, transform 0.28s ease;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-close {
  display: none;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  min-width: 0;
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
}

.brand-text {
  min-width: 0;
  transition: opacity 0.2s ease;
}

.brand-name {
  display: block;
  font-family: var(--heading);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.brand-tag {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.stat-compact {
  display: none;
}

/* Desktop collapsed sidebar */
.app.sidebar-collapsed .brand-text,
.app.sidebar-collapsed .nav-label,
.app.sidebar-collapsed .stat-label,
.app.sidebar-collapsed .stat-value,
.app.sidebar-collapsed .sidebar-foot {
  display: none;
}

.app.sidebar-collapsed .sidebar {
  padding: 1.25rem 0.7rem;
  align-items: center;
}

.app.sidebar-collapsed .brand {
  justify-content: center;
}

.app.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem;
}

.app.sidebar-collapsed .nav-icon {
  width: 24px;
  height: 24px;
}

.app.sidebar-collapsed .sidebar-stats {
  grid-template-columns: 1fr;
  width: 100%;
  gap: 0.5rem;
}

.app.sidebar-collapsed .stat {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.35rem;
}

.app.sidebar-collapsed .stat-compact {
  display: block;
  font-family: var(--heading);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: center;
}

.app.sidebar-collapsed .btn-logout {
  padding: 0.7rem;
  width: 100%;
}

.app.sidebar-collapsed .btn-logout .logout-icon {
  width: 22px;
  height: 22px;
  margin: 0;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  text-align: left;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item.active {
  background: var(--nav-gradient);
  color: #fff;
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.25);
}

.nav-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.sidebar-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: auto;
}

.stat {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.85rem;
}

.stat-value {
  display: block;
  font-family: var(--heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
}

.stat-label {
  font-size: 0.72rem;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-foot {
  margin: 0;
  font-size: 0.72rem;
  opacity: 0.45;
}

.nav-bottom {
  margin-top: 0;
}

.sidebar .btn-logout {
  margin-top: 0.15rem;
}

/* Main */
.main {
  padding: 1.75rem 2rem 2.5rem;
  width: 100%;
  max-width: none;
  min-width: 0;
  transition: padding 0.28s ease;
}

.app.sidebar-collapsed .main {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  flex-shrink: 0;
}

.topbar-actions[hidden] {
  display: none !important;
}

.topbar-leading {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.topbar-titles {
  min-width: 0;
}

.menu-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.menu-toggle:hover {
  border-color: var(--teal);
}

.menu-toggle-bar {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--green-deep);
  border-radius: 2px;
}

.topbar h1 {
  margin: 0;
  font-family: var(--heading);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--green-deep);
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.view {
  display: none;
  animation: fadeIn 0.28s ease;
}

.view.active {
  display: block;
}

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

/* Buttons — gold CTA like Registration / My Account */
.btn {
  border: 0;
  border-radius: var(--radius-pill);
  padding: 0.7rem 1.35rem;
  font-weight: 600;
  font-family: var(--heading);
  transition: transform 0.15s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--gold-gradient);
  color: var(--ink);
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

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

.btn-ghost:hover {
  background: rgba(19, 167, 155, 0.08);
  color: var(--ink);
  border-color: var(--teal);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 8px 14px rgba(255, 37, 58, 0.3);
}

.btn-inactive {
  border-color: #c4a35a;
  color: #8a6a1a;
}

.btn-inactive:hover {
  background: rgba(255, 198, 26, 0.18);
  border-color: var(--gold-dark);
  color: #6d5314;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
}

.search-wrap input,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  padding: 0.7rem 0.9rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-wrap input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 167, 155, 0.2);
}

/* Custom select — rounded trigger + rounded menu */
.custom-select {
  position: relative;
  min-width: 170px;
}

.field .custom-select {
  width: 100%;
  min-width: 0;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  padding: 0.7rem 0.9rem;
  text-align: left;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-select.open .custom-select-trigger,
.custom-select-trigger:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 167, 155, 0.2);
  outline: none;
}

.custom-select-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-chevron {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--ink-muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.custom-select.open .custom-select-chevron {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(1, 91, 39, 0.14);
  max-height: 260px;
  overflow-y: auto;
}

.custom-select-option {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.custom-select-option:hover {
  background: rgba(19, 167, 155, 0.1);
}

.custom-select-option.selected {
  background: var(--nav-gradient);
  color: #fff;
}

.view-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  flex-shrink: 0;
}

.toggle-btn {
  border: 0;
  background: transparent;
  padding: 0.55rem 0.75rem;
  color: var(--ink-muted);
}

.toggle-btn.active {
  background: rgba(19, 167, 155, 0.15);
  color: var(--green-deep);
}

/* Members grid / list */
.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
}

.members-grid.list-layout {
  grid-template-columns: 1fr;
}

.member-card {
  background: var(--surface);
  border: 1px solid rgba(213, 224, 218, 0.9);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  text-align: left;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.member-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(1, 91, 39, 0.14);
  border-color: rgba(19, 167, 155, 0.45);
}

.list-layout .member-card {
  flex-direction: row;
  align-items: center;
  gap: 1.15rem;
}

.member-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--green-mid);
  flex-shrink: 0;
  border: 3px solid #e8f6f3;
}

.list-layout .member-avatar {
  width: 56px;
  height: 56px;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 1.35rem;
  color: #ffffff;
  background: var(--green-mid);
  background-image: none;
}

.member-meta {
  flex: 1;
  min-width: 0;
}

.member-name {
  margin: 0;
  font-family: var(--heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green-deep);
}

.member-role {
  margin: 0.2rem 0 0;
  color: var(--gold-accent);
  font-size: 0.88rem;
  font-weight: 600;
}

.member-contact {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-block;
  font-family: var(--heading);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  background: rgba(29, 139, 76, 0.15);
  color: var(--green-mid);
  align-self: flex-start;
}

.status-pill.inactive {
  background: #eee;
  color: #666;
}

.status-pill.pending {
  background: rgba(255, 198, 26, 0.2);
  color: var(--gold-dark);
}

.empty-state {
  text-align: center;
  color: var(--ink-muted);
  padding: 3rem 1rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* Profile detail */
.back-link {
  border: 0;
  background: transparent;
  color: var(--teal);
  padding: 0;
  margin-bottom: 1.25rem;
  font-weight: 600;
}

.back-link:hover {
  color: var(--green-deep);
  text-decoration: underline;
}

.profile {
  background: var(--surface);
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  width: 100%;
}

.profile-banner {
  background: var(--section-gradient);
  display: flex;
  align-items: flex-end;
  min-height: 108px;
  padding: 1.1rem 1.75rem 0.7rem calc(1.75rem + 112px + 1.1rem);
  box-sizing: border-box;
}

.profile-name {
  margin: 0;
  font-family: var(--heading);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.profile-body {
  padding: 0.7rem 1.75rem 1.75rem;
  margin-top: 0;
  position: relative;
}

.profile-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  min-height: 56px;
}

.profile-photo {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  box-shadow: 0 6px 20px rgba(1, 91, 39, 0.2);
  background: var(--green-mid);
  flex-shrink: 0;
  position: absolute;
  top: -56px;
  left: 1.75rem;
  z-index: 2;
}

.profile-photo.avatar-fallback {
  background: var(--green-mid);
  color: #ffffff;
  font-size: 1.75rem;
}

.profile-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  min-width: 0;
  flex: 1;
  margin-left: calc(112px + 1.1rem);
  padding-top: 0.1rem;
}

.profile-title .role-line {
  margin: 0;
  color: var(--gold-accent);
  font-weight: 600;
}

.profile-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-self: flex-start;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem 1.5rem;
}

.detail-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 0.3rem;
}

.detail-value {
  font-size: 0.98rem;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-value a {
  color: var(--teal);
}

/* Form */
.member-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  width: 100%;
}

.form-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  width: 100%;
}

.photo-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  position: sticky;
  top: 1rem;
}

.photo-upload {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 2px dashed var(--line);
  background: rgba(19, 167, 155, 0.08);
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.photo-upload:hover {
  border-color: var(--teal);
  background: rgba(19, 167, 155, 0.16);
}

.photo-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem;
}

.photo-plus {
  font-size: 1.6rem;
  color: var(--teal);
  line-height: 1;
}

.fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--ink);
}

.req {
  color: var(--danger);
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--green-deep);
  color: #fff;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  max-width: 320px;
  font-weight: 600;
}

.toast.show {
  opacity: 1;
  transform: none;
}

/* Activity logs */
.logs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.logs-summary {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.logs-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.log-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem 1rem;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1.15rem;
  box-shadow: var(--shadow);
}

.log-badge {
  font-family: var(--heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(19, 167, 155, 0.15);
  color: var(--green-mid);
  white-space: nowrap;
}

.log-badge.member {
  background: rgba(29, 139, 76, 0.15);
  color: var(--green-deep);
}

.log-badge.role {
  background: rgba(255, 198, 26, 0.22);
  color: var(--gold-dark);
}

.log-badge.auth {
  background: rgba(1, 91, 39, 0.12);
  color: var(--green-deep);
}

.log-badge.delete {
  background: rgba(255, 37, 58, 0.12);
  color: var(--danger);
}

.log-body {
  min-width: 0;
}

.log-title {
  margin: 0;
  font-family: var(--heading);
  font-weight: 700;
  color: var(--green-deep);
  font-size: 0.98rem;
}

.log-detail {
  margin: 0.25rem 0 0;
  color: var(--ink);
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-meta {
  margin: 0.4rem 0 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

/* Roles management */
.role-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.role-add-form .field {
  flex: 1;
  min-width: 200px;
}

.roles-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1.15rem;
  box-shadow: var(--shadow);
}

.role-row-info {
  min-width: 0;
}

.role-row-name {
  margin: 0;
  font-family: var(--heading);
  font-weight: 700;
  color: var(--green-deep);
}

.role-row-meta {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* Confirm dialog */
.confirm-dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  max-width: 380px;
}

.confirm-dialog::backdrop {
  background: rgba(1, 91, 39, 0.5);
}

.confirm-box {
  padding: 1.5rem;
}

.confirm-box h3 {
  margin: 0 0 0.5rem;
  font-family: var(--heading);
  color: var(--green-deep);
}

.confirm-box p {
  margin: 0 0 1.25rem;
  color: var(--ink-muted);
}

/* ========== Responsive ========== */

/* Large tablets / small laptops */
@media (max-width: 1100px) {
  .main,
  .app.sidebar-collapsed .main {
    padding: 1.5rem 1.35rem 2rem;
  }

  .members-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  }
}

/* Tablets & phones — off-canvas sidebar drawer */
@media (max-width: 900px) {
  .app,
  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
    --sidebar-width: 280px;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(1, 91, 39, 0.45);
    z-index: 55;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
  }

  .sidebar-overlay[hidden] {
    display: none !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    height: 100vh;
    height: 100dvh;
    padding: 1.15rem 1.1rem;
    gap: 1.15rem;
    transform: translateX(-105%);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.28);
  }

  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Reset desktop collapsed styles on mobile */
  .app.sidebar-collapsed .brand-text,
  .app.sidebar-collapsed .nav-label,
  .app.sidebar-collapsed .stat-label,
  .app.sidebar-collapsed .stat-value,
  .app.sidebar-collapsed .sidebar-foot {
    display: revert;
  }

  .app.sidebar-collapsed .stat-compact {
    display: none;
  }

  .app.sidebar-collapsed .sidebar {
    padding: 1.15rem 1.1rem;
    align-items: stretch;
  }

  .app.sidebar-collapsed .nav-item {
    justify-content: flex-start;
    padding: 0.7rem 1rem;
  }

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

  .app.sidebar-collapsed .btn-logout {
    padding: 0.65rem 1rem;
    font-size: 0.88rem;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .brand {
    align-items: center;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
  }

  .sidebar-stats {
    margin-top: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.45rem;
  }

  .nav-item {
    justify-content: flex-start;
    min-height: 44px;
    width: 100%;
  }

  .sidebar .btn-logout {
    width: 100%;
  }

  .sidebar-foot {
    display: block;
  }

  .form-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .photo-panel {
    position: static;
  }

  .fields {
    width: 100%;
  }

  .detail-grid,
  .field-row {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 1.15rem 1rem 2rem;
  }

  .profile-actions {
    margin-left: 0;
    width: 100%;
  }

  .profile-actions .btn {
    flex: 1 1 auto;
  }

  .toolbar .custom-select {
    flex: 1 1 160px;
    min-width: 0;
  }

  .view-toggle {
    margin-left: auto;
  }

  body.sidebar-lock {
    overflow: hidden;
  }
}

/* Phones */
@media (max-width: 640px) {
  body {
    background-attachment: scroll;
  }

  .login-screen {
    padding: 1rem;
    align-items: flex-start;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .login-card {
    padding: 1.35rem 1.1rem 1.15rem;
    border-radius: 16px;
    max-width: 100%;
  }

  .login-logo {
    width: 80px;
    height: 80px;
  }

  .login-title {
    font-size: 1.1rem;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    margin-bottom: 1.15rem;
  }

  .topbar-leading {
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 1.4rem;
  }

  .subtitle {
    font-size: 0.88rem;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 0.4rem);
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .search-wrap {
    min-width: 0;
    width: 100%;
  }

  .toolbar .custom-select {
    width: 100%;
    flex: none;
  }

  .view-toggle {
    margin-left: 0;
    width: 100%;
  }

  .view-toggle .toggle-btn {
    flex: 1;
  }

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

  .list-layout .member-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .member-card {
    padding: 1rem;
  }

  .member-form {
    padding: 1.1rem;
  }

  .photo-upload {
    width: 132px;
    height: 132px;
  }

  .profile-banner {
    min-height: 96px;
    padding: 1rem 1rem 0.65rem calc(1rem + 96px + 0.85rem);
  }

  .profile-name {
    font-size: 1.35rem;
  }

  .profile-body {
    padding: 0.65rem 1rem 1.25rem;
  }

  .profile-photo {
    width: 96px;
    height: 96px;
    top: -48px;
    left: 1rem;
  }

  .profile-title {
    margin-left: calc(96px + 0.85rem);
  }

  .profile-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
    min-height: 48px;
  }

  .profile-actions {
    flex-direction: column;
    width: 100%;
    margin-left: 0;
  }

  .profile-actions .btn {
    width: 100%;
  }

  .profile-title {
    width: 100%;
  }

  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
  }

  .role-add-form {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
  }

  .role-add-form .field {
    min-width: 0;
    width: 100%;
  }

  .role-add-form .btn {
    width: 100%;
  }

  .role-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .role-row .btn {
    width: 100%;
  }

  .logs-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .log-row {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    max-width: none;
    text-align: center;
  }

  .confirm-dialog {
    width: calc(100% - 1.5rem);
    max-width: 380px;
    margin: auto;
  }
}

/* Small phones */
@media (max-width: 400px) {
  .sidebar {
    padding: 1rem 0.9rem;
  }

  .brand-name {
    font-size: 0.88rem;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .nav-item {
    font-size: 0.82rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .main {
    padding: 0.9rem 0.75rem 1.5rem;
  }

  .topbar h1 {
    font-size: 1.25rem;
  }

  .member-avatar {
    width: 64px;
    height: 64px;
  }

  .empty-state {
    padding: 2rem 0.85rem;
    font-size: 0.9rem;
  }
}

/* Short landscape phones / small height */
@media (max-height: 500px) and (orientation: landscape) {
  .login-screen {
    align-items: stretch;
    padding: 0.75rem;
  }

  .login-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem 1.25rem;
    align-items: center;
    max-width: 640px;
    text-align: left;
    padding: 1rem 1.25rem;
  }

  .login-logo {
    width: 64px;
    height: 64px;
    margin: 0;
    grid-row: span 2;
  }

  .login-title {
    font-size: 1rem;
    margin: 0;
  }

  .login-subtitle {
    margin: 0.15rem 0 0;
    grid-column: 2;
  }

  .login-form,
  .login-hint {
    grid-column: 1 / -1;
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
