:root {
  --cloud-white: #f6f7f8;
  --jet: #18181b;
  --light-gray: #e4e7ec;
  --medium-gray: #737984;
  --accent: #202124;
  --success: #177245;
  --warning: #9a6700;
  --danger: #b42318;
  --admin-surface: #ffffff;
  --admin-subtle: #f8f9fa;
  --admin-border: #e2e5e9;
  --admin-text-soft: #69707d;
  --transition: 160ms ease;
}

html { background: var(--cloud-white); }

body {
  background: var(--cloud-white);
  color: var(--jet);
  font-size: 14px;
  line-height: 1.5;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
}

.admin-header {
  min-height: 72px;
  padding: 0 28px;
  color: var(--jet);
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--admin-border);
  box-shadow: none;
  backdrop-filter: blur(12px);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.admin-brand-link {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.admin-brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: #1f2023;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: -.03em;
}

.admin-brand-copy { display: grid; line-height: 1.15; }
.admin-title { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.admin-brand-copy small { margin-top: 3px; color: var(--admin-text-soft); font-size: 11px; font-weight: 500; }

.admin-menu-toggle {
  width: 38px;
  height: 38px;
  display: none;
  place-items: center;
  border: 1px solid var(--admin-border);
  border-radius: 9px;
  color: var(--jet);
  background: #fff;
  cursor: pointer;
}

.admin-user-info { gap: 8px; }

.admin-site-btn,
.admin-logout-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--admin-border);
  border-radius: 9px;
  color: #30343b;
  background: #fff;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}

.admin-site-btn:hover,
.admin-logout-btn:hover { background: #f4f5f6; border-color: #cfd3d9; }
.admin-logout-btn { color: var(--danger); cursor: pointer; }

.admin-sidebar {
  top: 72px;
  width: 248px;
  height: calc(100vh - 72px);
  padding: 22px 12px;
  background: #fff;
  border-right: 1px solid var(--admin-border);
  z-index: 900;
}

.sidebar-label {
  padding: 0 12px 9px;
  color: #9a9faa;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.sidebar-menu li { margin: 2px 0; }

.sidebar-menu a {
  min-height: 42px;
  gap: 11px;
  margin: 0;
  padding: 0 12px;
  border-radius: 9px;
  color: #4d535d;
  font-size: 13px;
  font-weight: 560;
  transition: color var(--transition), background var(--transition);
}

.sidebar-menu a i {
  width: 18px;
  color: #8a909a;
  font-size: 14px;
  text-align: center;
}

.sidebar-menu a:hover { color: var(--jet); background: #f3f4f5; }
.sidebar-menu a.active { color: #fff; background: #202124; }
.sidebar-menu a.active i { color: #fff; }

.sidebar-menu a .badge {
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: #b42318;
  font-size: 10px;
  font-weight: 700;
}

.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 72px 0 0;
  z-index: 850;
  border: 0;
  background: rgba(15, 17, 20, .32);
}

.admin-content {
  margin-top: 72px;
  margin-left: 248px;
  min-height: calc(100vh - 72px);
  padding: 34px 36px 56px;
}

.content-section { width: min(100%, 1480px); margin: 0 auto; }

.content-header {
  min-height: 44px;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
  padding: 0;
  border: 0;
}

.content-title {
  color: #1c1d20;
  font-size: clamp(24px, 2.4vw, 31px);
  font-weight: 720;
  letter-spacing: -.035em;
}

.content-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  box-shadow: none;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.btn:hover { transform: none; filter: none; }
.btn-primary { color: #fff; background: #202124; border-color: #202124; }
.btn-primary:hover { background: #34363a; border-color: #34363a; }
.btn-secondary { color: #373b42; background: #fff; border-color: var(--admin-border); }
.btn-secondary:hover { background: #f4f5f6; border-color: #ccd0d6; }
.btn-success { color: #fff; background: #176b44; border-color: #176b44; }
.btn-danger { color: #a52a22; background: #fff; border-color: #e5c5c2; }
.btn-danger:hover { color: #fff; background: #b42318; border-color: #b42318; }
.btn:disabled { cursor: wait; opacity: .55; }

.dashboard-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.dashboard-card {
  min-width: 0;
  min-height: 142px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid var(--admin-border);
  border-radius: 13px;
  background: var(--admin-surface);
  box-shadow: 0 1px 2px rgba(16,24,40,.03);
  text-align: left;
}

.dashboard-card:hover { transform: none; border-color: #cfd3d8; box-shadow: 0 1px 2px rgba(16,24,40,.04); }

.card-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  margin: 0;
  border-radius: 9px;
  color: #565d68;
  background: #f1f2f4;
  font-size: 14px;
}

.card-value { margin: 14px 0 1px; color: #1b1d20; font-size: 29px; font-weight: 720; letter-spacing: -.04em; line-height: 1; }
.card-label { color: var(--admin-text-soft); font-size: 12px; font-weight: 520; }

.data-table {
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid var(--admin-border);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16,24,40,.025);
}

.table-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--admin-border);
  color: #292d33;
  background: #fff;
  font-size: 13px;
  font-weight: 680;
}

.people-directory-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.people-directory-heading small {
  color: var(--admin-text-soft);
  font-size: 11px;
  font-weight: 500;
}

.table-columns {
  min-width: 920px;
  display: grid;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--admin-border);
  color: #8a909a;
  background: #fafafa;
  font-size: 10px;
  font-weight: 720;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.users-columns { grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 1fr 150px; min-width: 1120px; }
.messages-columns,
.contacts-columns { grid-template-columns: 1.5fr 2fr 1fr .8fr 120px; }
.events-columns { grid-template-columns: 2fr 1fr 1fr .8fr 120px; }
.materials-columns { grid-template-columns: 2fr 1fr .8fr .8fr 150px; }
.requests-columns { grid-template-columns: 1fr 1.2fr 1fr 1.4fr 170px; }

.table-body { max-height: 640px; overflow: auto; }

.admin-list-viewport {
  min-height: 0 !important;
  overflow: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: #b8bdc6 #f4f5f6;
  align-content: start;
}
.admin-list-viewport:focus-visible {
  outline: 2px solid var(--admin-accent);
  outline-offset: -2px;
}

.people-directory-viewport {
  max-height: none;
  overscroll-behavior: contain;
  scrollbar-color: #b8bdc6 #f4f5f6;
  scrollbar-gutter: stable;
}

.people-directory-viewport.is-scrollable {
  box-shadow: inset 0 -18px 18px -22px rgba(28, 31, 36, .75);
}

.people-directory-viewport:focus-visible {
  outline: 2px solid var(--admin-accent);
  outline-offset: -2px;
}

.table-row {
  min-width: 920px;
  gap: 18px;
  padding: 15px 18px;
  border-bottom: 1px solid #eceef1;
  color: #34383f;
  background: #fff !important;
  font-size: 12px;
}

#usersTable .table-row { min-width: 1120px; }
.table-row:last-child { border-bottom: 0; }
.table-row:hover { background: #fafbfb !important; }
.table-row strong { color: #23262b; font-weight: 650; }
.table-row small { color: var(--admin-text-soft) !important; line-height: 1.55; }
.table-row > div:last-child { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }

.user-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: capitalize;
}

.status-active { color: #146c43; background: #edf8f2; border-color: #cee9da; }
.status-pending { color: #8a5b00; background: #fff8e6; border-color: #f0deb0; }
.status-inactive,
.status-rejected,
.status-suspended { color: #a52a22; background: #fff1f0; border-color: #efcfcc; }

.action-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  color: #555c66;
  background: #fff;
  font-size: 12px;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.action-btn:hover { color: #fff; background: #303238; border-color: #303238; }
.action-btn.success { color: #176b44; background: #f2faf5; border-color: #cce6d7; }
.action-btn.danger { color: #a52a22; background: #fff; border-color: #ead1cf; }
.action-btn.danger:hover { color: #fff; background: #b42318; border-color: #b42318; }

.loading { padding: 42px 20px; color: var(--admin-text-soft); font-size: 12px; }
.spinner { margin-bottom: 9px; color: #777d87; font-size: 20px; }

.form-group { margin-bottom: 18px; }
.form-label { margin-bottom: 7px; color: #383c43; font-size: 12px; font-weight: 650; }
.form-input,
.form-select,
.form-textarea,
.chat-input input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8dce1;
  border-radius: 9px;
  color: #272a2f;
  background: #fff;
  box-shadow: none;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.chat-input input:focus { border-color: #8a9098; box-shadow: 0 0 0 3px rgba(31,32,35,.06); }
.form-textarea { min-height: 110px; }

.modal { padding: 24px; background: rgba(19,21,24,.42); backdrop-filter: blur(3px); }
.modal-content { width: min(100%, 620px); border: 1px solid rgba(255,255,255,.5); border-radius: 14px; box-shadow: 0 24px 70px rgba(12,14,18,.18); }
.modal-header,
.modal-footer { padding: 17px 20px; }
.modal-body { padding: 20px; }
.modal-title { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.modal-header .btn { width: 34px; min-height: 34px; padding: 0; font-size: 17px !important; }

.chats-container {
  min-height: 620px;
  grid-template-columns: minmax(260px, 31%) 1fr;
  border: 1px solid var(--admin-border);
  border-radius: 13px;
  box-shadow: 0 1px 2px rgba(16,24,40,.025);
}

.users-list { background: #fafafa; border-color: var(--admin-border); }
.conversation-item { padding: 14px 16px; border-color: var(--admin-border); font-size: 12px; }
.conversation-item:hover,
.conversation-item.active { background: #f0f1f2; }
.chat-messages { max-height: 560px; padding: 20px; }
.chat-input { padding: 14px; border-color: var(--admin-border); }
.admin-chat-bubble { max-width: min(76%, 640px); padding: 10px 12px; border-radius: 11px; font-size: 12px; }
.admin-chat-bubble.user { background: #f0f1f2; }
.admin-chat-bubble.admin { color: #fff; background: #26282c; }

#settings-section .dashboard-grid { grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr) minmax(260px, .7fr); }
#settings-section .dashboard-card { min-height: auto; display: block; text-align: left; }
#settings-section .dashboard-card h3 { font-size: 14px; font-weight: 700; }

#legacyImportStatus { border: 1px solid #d9deeb; font-size: 12px; line-height: 1.55; }

@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  #settings-section .dashboard-grid { grid-template-columns: 1fr 1fr; }
  #settings-section .dashboard-card:first-child { grid-column: 1 / -1 !important; }
}

@media (max-width: 900px) {
  .admin-header { min-height: 64px; padding: 0 16px; }
  .admin-menu-toggle { display: grid; }
  .admin-brand-mark { display: none; }
  .admin-sidebar {
    top: 64px;
    height: calc(100vh - 64px);
    transform: translateX(-104%);
    box-shadow: 18px 0 42px rgba(18,20,24,.13);
    transition: transform 180ms ease;
  }
  .admin-sidebar.show { transform: translateX(0); }
  .admin-sidebar-backdrop.show { display: block; inset: 64px 0 0; }
  .admin-content { margin-top: 64px; margin-left: 0; padding: 26px 20px 44px; }
  .content-header { align-items: flex-start; flex-direction: column; gap: 14px; }
  .content-actions { width: 100%; justify-content: flex-start; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .chats-container { grid-template-columns: 1fr; }
  .users-list { max-height: 235px; border-right: 0; border-bottom: 1px solid var(--admin-border); }
  .table-columns { display: none !important; }
  .table-row,
  #usersTable .table-row { min-width: 0 !important; grid-template-columns: 1fr !important; gap: 8px; padding: 14px; }
  .table-row > div { min-width: 0; overflow-wrap: anywhere; }
  .table-row > div:last-child { padding-top: 8px; border-top: 1px solid var(--admin-border); }
  .volunteer-ops-grid,
  .ops-report-grid { grid-template-columns: 1fr; }
  .ops-form-grid { grid-template-columns: 1fr; }
  .ops-form-grid .full { grid-column: auto; }
}

@media (max-width: 620px) {
  .admin-header { padding: 0 12px; }
  .admin-brand-copy small { display: none; }
  .admin-title { font-size: 14px; }
  .admin-site-btn { width: 38px; padding: 0; font-size: 0; }
  .admin-site-btn i { font-size: 12px; }
  .admin-logout-btn { padding: 0 10px; }
  .admin-content { padding: 22px 14px 38px; }
  .content-title { font-size: 25px; }
  .content-actions .btn { flex: 1 1 auto; }
  .content-actions { display:grid; grid-template-columns:1fr; overflow:visible; }
  .content-actions .btn,
  .content-actions a { width:100%; min-height:44px; }
  .people-directory-heading { align-items:flex-start; flex-direction:column; gap:4px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .dashboard-card { min-height: 126px; padding: 15px; }
  .card-value { font-size: 25px; }
  #settings-section .dashboard-grid { grid-template-columns: 1fr; }
  #settings-section .dashboard-card { grid-column: auto !important; }
  .modal { padding: 10px; }
  .modal-content { max-height: 96vh; border-radius: 12px; }
  .ops-collapse-heading { align-items:center; }
  .ops-collapse-toggle { min-height:40px; font-size:0; padding:.55rem .75rem; }
  .ops-collapse-toggle i { font-size:.85rem; }
}
/* Author display rules (flex/grid) must not override permission-based hiding. */
[data-admin-permission][hidden] {
    display: none !important;
}
