/* ============================================================================
   Phoenix Vanguard — Admin Portal styles
   ----------------------------------------------------------------------------
   Layout shell only: ink-dark sidebar + flexible main area. All colors
   reference the existing CSS variables from /css/styles.css so the site's
   light/dark theme toggle works for the portal without extra JS.
   The sidebar scopes `data-theme="dark"` onto itself so its text colors
   resolve against the dark-mode variable branch regardless of the site theme
   — the sidebar surface is always dark by design.
   ============================================================================ */

html, body { height: 100%; }
body { overflow: hidden; } /* shell scrolls inside .portal-main */

.portal-boot {
  padding: 2rem;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  color: var(--text-secondary);
}

/* --------------- Shell grid --------------- */
.portal-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: "side main";
  width: 100%;
  height: 100vh;
  height: 100dvh; /* use dynamic viewport height on mobile so the topbar
                     doesn't slip out of the visible area when the address
                     bar / virtual keyboard resizes the viewport */
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* --------------- Sidebar (desktop rail) ---------------
   Light theme: parchment-darker panel, dark text.
   Dark theme:  card-dark panel, light text. Both resolve via the
   scoped variables below so the site theme toggle drives them. */
.portal-sidebar {
  background: var(--bg-darker);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
}
[data-theme="dark"] .portal-sidebar {
  background: var(--bg-card);
  border-right-color: var(--border-color);
}
.portal-sidebar-rail {
  grid-area: side;
  padding: 1.25rem 0 0;
}

.portal-sidebar-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100%;
}

.portal-sidebar .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
  text-decoration: none;
}
.portal-sidebar .sidebar-logo {
  height: 44px;
  width: 44px;
}
.portal-sidebar .sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.portal-sidebar .sidebar-brand-title {
  font-family: 'Stoke', serif;
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-primary);
  line-height: 1.1;
}
.portal-sidebar .sidebar-brand-subtitle {
  font-family: 'La Belle Aurore', cursive;
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.2;
  margin-top: 0.15rem;
}

.portal-sidebar .sidebar-user {
  padding: 0.25rem 1.25rem 0.9rem;
  font-family: 'Crimson Pro', serif;
  color: var(--text-secondary);
}
.portal-sidebar .sidebar-user .sidebar-user-name {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 0.15rem;
}
.portal-sidebar .sidebar-user .sidebar-user-roles {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-brown);
  margin: 0;
}

.portal-sidebar .sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.5rem 0.5rem;
  flex: 1;
}
.portal-sidebar .sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.portal-sidebar .sidebar-nav-group + .sidebar-nav-group {
  margin-top: 0.9rem;
}
.portal-sidebar .sidebar-nav-group-title {
  margin: 0;
  padding: 0.3rem 0.85rem 0.35rem;
  font-family: 'Stoke', serif;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.portal-sidebar .sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-primary);
  font-family: 'Stoke', serif;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.portal-sidebar .sidebar-nav-item .material-icons {
  font-size: 18px;
  color: var(--text-primary);
}
.portal-sidebar .sidebar-nav-item:hover { background: var(--bg-card-light); }
.portal-sidebar .sidebar-nav-item.is-active {
  background: var(--bg-card);
  color: var(--text-primary);
}
[data-theme="dark"] .portal-sidebar .sidebar-nav-item:hover { background: var(--bg-card-light); }
[data-theme="dark"] .portal-sidebar .sidebar-nav-item.is-active { background: var(--bg-darker); }
.portal-sidebar .sidebar-nav-item.is-active .material-icons { color: var(--accent-red); }

.portal-sidebar .sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.portal-sidebar .sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: 'Stoke', serif;
  font-size: .85rem;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
}
.portal-sidebar .sidebar-footer-btn .material-icons {
  font-size: 18px;
  color: var(--text-secondary);
}
.portal-sidebar .sidebar-footer-btn:hover {
  background: var(--bg-card-light);
  color: var(--text-primary);
}

/* --------------- Main --------------- */
.portal-main {
  grid-area: main;
  overflow-y: auto;
  padding: 1.75rem 2rem 3rem;
  font-family: 'Crimson Pro', serif;
  font-size: 1.05rem;
}
.portal-main .portal-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.portal-main .portal-section-header > .material-icons {
  font-size: 32px;
  color: var(--accent-red);
}
.portal-main .portal-section-header h1 {
  margin: 0;
  font-family: 'Stoke', serif;
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

/* --------------- Top bar (mobile/tablet) --------------- */
.portal-topbar {
  display: none;
  grid-area: topbar;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg-darker);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}
[data-theme="dark"] .portal-topbar { background: var(--bg-card); }
.portal-topbar-hamburger {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  width: 34px;
  height: 28px;
  padding: 5px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
}
[data-theme="dark"] .portal-topbar-hamburger { background: var(--bg-darker); }
.portal-topbar-hamburger:hover { filter: brightness(0.95); }
.portal-topbar-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
}
.portal-topbar-brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.portal-topbar-logo {
  height: 32px;
  width: 32px;
}
.portal-topbar-title {
  font-family: 'Stoke', serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-left: auto;
}

/* --------------- Mobile drawer --------------- */
.portal-sidebar-drawer {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: min(320px, 86vw);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0,0,0,0.35);
  display: none;  /* hidden on desktop */
}
.portal-sidebar-drawer.is-open { transform: translateX(0); }
.portal-drawer-header {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem 0;
}
.portal-drawer-close {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.portal-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.portal-drawer-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* --------------- Cards --------------- */
.portal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.25rem 1.25rem;
  margin-bottom: 1.25rem;
}
.portal-card .portal-card-title {
  font-family: 'Stoke', serif;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0;
}
.portal-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.portal-card-header > .portal-card-title { flex: 1; }
.portal-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.portal-search {
  background: var(--form-input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 0.7rem;
  border-radius: 4px;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  min-width: 16rem;
}

.portal-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  align-items: center;
  margin: 0.35rem 0 0.85rem;
}
.portal-filter-select {
  background: var(--form-input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.4rem 0.55rem;
  border-radius: 4px;
  font-family: 'Crimson Pro', serif;
  font-size: 0.95rem;
  min-width: 11rem;
}

/* --------------- Tables --------------- */
.portal-table-wrap { overflow-x: auto; }
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Crimson Pro', serif;
  font-size: 1.05rem;
}
.portal-table thead th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-family: 'Stoke', serif;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card-light);
}
.portal-table tbody td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: top;
}
.portal-table tbody tr:hover { background: var(--bg-card-light); }

/* Tables sit flush to the card edges. Any header / subtitle / filter content
   above the table keeps the card's normal padding; the table itself breaks
   out to the card border so its banded header and rows run edge-to-edge.
   First/last cell content is re-inset to line up with the padded content. */
.portal-card:has(> .portal-table-wrap) { overflow: hidden; }
.portal-card > .portal-table-wrap {
  margin: 0 -1.25rem -1.25rem;
}
.portal-card > .portal-table-wrap:first-child { margin-top: -1.25rem; }
.portal-card > .portal-table-wrap .portal-table th:first-child,
.portal-card > .portal-table-wrap .portal-table td:first-child { padding-left: 1.25rem; }
.portal-card > .portal-table-wrap .portal-table th:last-child,
.portal-card > .portal-table-wrap .portal-table td:last-child { padding-right: 1.25rem; }

/* --------------- Inline buttons --------------- */
.portal-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: var(--accent-brown);
  color: #fff;
  border: 1px solid var(--accent-brown);
  border-radius: 4px;
  font-family: 'Stoke', serif;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.portal-btn:hover { filter: brightness(1.05); }
.portal-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.portal-btn.is-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-color);
}
.portal-btn.is-ghost:hover { background: var(--bg-card-light); }
.portal-btn.is-danger {
  background: var(--accent-red);
  border-color: var(--accent-red);
}
.portal-btn.is-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
}
.portal-btn .material-icons { font-size: 18px; }

/* --------------- Form fields --------------- */
.portal-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}
.portal-field label {
  font-family: 'Stoke', serif;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.portal-field input[type="text"],
.portal-field input[type="date"],
.portal-field textarea,
.portal-field select {
  background: var(--form-input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.55rem 0.65rem;
  border-radius: 4px;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
}
.portal-field textarea { min-height: 5rem; resize: vertical; }
.portal-field-help {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}
.portal-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}
.portal-form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* --------------- Grouped form sections ---------------
   Used by sectioned RecordForm (e.g. patient edit form mirrors the
   patient intake form: Patient Information → Emergency Contact →
   Pre-Existing Conditions). */
.portal-form-section {
  margin-bottom: 1.25rem;
}
.portal-form-section + .portal-form-section {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}
.portal-form-section-title {
  margin: 0 0 0.65rem;
  font-family: 'Stoke', serif;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-brown);
}

/* --------------- Flash --------------- */
.portal-flash {
  padding: 0.7rem 0.9rem;
  border-radius: 4px;
  margin: 0.5rem 0 0.75rem;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
}
.portal-flash.error   { background: rgba(165, 77, 68, 0.12); color: var(--accent-red); border: 1px solid rgba(165, 77, 68, 0.35); }
.portal-flash.success { background: rgba(90, 138, 60, 0.12); color: var(--check-color); border: 1px solid rgba(90, 138, 60, 0.35); }

/* --------------- Talked-to checkbox cell --------------- */
.talked-to-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
}
.talked-to-cell input[type="checkbox"] {
  accent-color: var(--check-color);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* --------------- Faction tag chips (read-only display) --------------- */
.portal-faction-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.portal-faction-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: 'Stoke', serif;
  font-size: 0.75rem;
  white-space: nowrap;
  line-height: 1;
}

/* --------------- Checkbox group (multi-select form field) --------------- */
.portal-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  padding: 0.5rem 0.65rem;
  background: var(--form-input-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}
.portal-checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-primary);
}
.portal-checkbox-option input[type="checkbox"] {
  accent-color: var(--check-color);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* --------------- Coming soon --------------- */
.portal-coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
  color: var(--text-secondary);
  font-family: 'Crimson Pro', serif;
}
.portal-coming-soon .material-icons {
  font-size: 64px;
  color: var(--accent-brown);
  margin-bottom: 0.75rem;
}
.portal-coming-soon h2 {
  font-family: 'Stoke', serif;
  font-size: 1.3rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
}
.portal-coming-soon p {
  margin: 0;
  font-family: 'La Belle Aurore', cursive;
  font-size: 1.15rem;
}

/* --------------- Badges --------------- */
.portal-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-darker);
  color: var(--text-primary);
  font-family: 'Stoke', serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.portal-badge.is-pinned { background: rgba(165, 77, 68, 0.15); color: var(--accent-red); }
.portal-badge.is-ok     { background: rgba(90, 138, 60, 0.15); color: var(--check-color); }

/* --------------- Admin Settings role checkboxes --------------- */
.admin-role-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
}
.admin-role-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: 'Crimson Pro', serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  user-select: none;
}
.admin-role-checkbox input[type="checkbox"] {
  accent-color: var(--check-color);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* --------------- Modal --------------- */
.portal-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3vh 1rem 1rem;
  overflow-y: auto;
}
.portal-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  max-height: 94vh;
}
.portal-modal-lg { max-width: 880px; }
.portal-modal-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card-light);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.portal-modal-title {
  margin: 0;
  flex: 1;
  font-family: 'Stoke', serif;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.portal-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.portal-modal-close:hover { color: var(--text-primary); }
.portal-modal-body {
  padding: 1rem 1.1rem 1.25rem;
  overflow-y: auto;
}

/* --------------- Dashboard --------------- */
.dashboard-header .dashboard-date {
  margin-left: auto;
  font-family: 'La Belle Aurore', cursive;
  font-size: 1.2rem;
  color: var(--accent-brown);
  white-space: nowrap;
}

.dash-loading {
  color: var(--text-secondary);
  font-style: italic;
}

/* Pending / Scheduled groups side by side on wide views, stacking when the
   row can no longer fit two groups. */
.dash-stat-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}
.dash-stat-heading {
  margin: 0 0 0.5rem;
  font-family: 'Stoke', serif;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.dash-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.dash-stat {
  flex: 1 1 160px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 1.1rem 1.25rem;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.dash-stat:hover { background: var(--bg-card-light); }
.dash-stat.is-alert { border-color: var(--accent-red); }
.dash-stat-num {
  font-family: 'Stoke', serif;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--text-primary);
}
.dash-stat.is-alert .dash-stat-num { color: var(--accent-red); }
.dash-stat-label {
  font-family: 'Stoke', serif;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.dash-attention-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.dash-attention-head .portal-card-title { flex: 1; }
.dash-attention-meta {
  font-family: 'Crimson Pro', serif;
  font-size: 0.95rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.dash-attention-list { display: flex; flex-direction: column; }
.dash-attention-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border-color);
}
.dash-attention-row:first-child { border-top: none; }
.dash-attention-text {
  flex: 1;
  min-width: 0;
  font-family: 'Crimson Pro', serif;
  font-size: 1.02rem;
  color: var(--text-primary);
}
.dash-attention-source {
  font-family: 'La Belle Aurore', cursive;
  font-style: normal;
  color: var(--text-secondary);
  margin-left: 0.2rem;
}
.dash-attention-empty {
  color: var(--text-secondary);
  font-style: italic;
  margin: 0.4rem 0 0;
}
.dash-open { white-space: nowrap; }
.dash-open .material-icons { font-size: 16px; }

/* --------------- Pills ---------------
   Outlined status chips shared by the dashboard, division cards, and the
   applications/job stage badges. Variants: red-fill (action), red / gold /
   green / muted outlines. */
.portal-pill {
  flex-shrink: 0;
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: 'Stoke', serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
}
.portal-pill.is-red-fill { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }
.portal-pill.is-red      { color: var(--accent-red);    border-color: var(--accent-red); }
.portal-pill.is-gold     { color: var(--accent-brown);  border-color: var(--accent-brown); }
.portal-pill.is-green    { color: var(--check-color);   border-color: var(--check-color); }
.portal-pill.is-muted    { color: var(--text-secondary); border-color: var(--border-color); }

/* --------------- Division layout --------------- */
.division-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 1.25rem;
  align-items: start;
}
.division-col { min-width: 0; }

.portal-card-subtitle {
  margin: -0.25rem 0 0.9rem;
  color: var(--text-secondary);
  font-family: 'Crimson Pro', serif;
  font-size: 0.98rem;
}
.portal-card-count {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: 'Crimson Pro', serif;
  white-space: nowrap;
}

/* IC Interview card */
.ic-interview-list { display: flex; flex-direction: column; }
.ic-interview-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border-color);
}
.ic-interview-row:first-child { border-top: none; }
.ic-interview-name {
  font-family: 'Crimson Pro', serif;
  font-weight: 600;
  color: var(--text-primary);
}

/* Bulletins (shared board) */
.bulletin-list { display: flex; flex-direction: column; gap: 0.85rem; }
.bulletin-item {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  background: var(--bg-card-light);
}
.bulletin-item.is-pinned { border-color: var(--accent-red); }

/* Dashed empty state */
.portal-empty {
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-family: 'Crimson Pro', serif;
}

/* --------------- FC Members directory --------------- */
.members-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Segmented All / Needs attention toggle */
.portal-chip-group {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}
.portal-chip {
  padding: 0.45rem 0.95rem;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: 'Stoke', serif;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.portal-chip:last-child { border-right: none; }
.portal-chip:hover { background: var(--bg-card-light); color: var(--text-primary); }
.portal-chip.is-active { background: var(--accent-brown); color: #fff; }

/* Notes inline link (replaces a bordered button in the Notes column) */
.notes-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent-brown);
  font-family: 'Crimson Pro', serif;
  font-size: 1.02rem;
  white-space: nowrap;
  cursor: pointer;
}
.notes-link:hover { text-decoration: underline; }

/* Rank group banding */
/* Table row banding for grouped tables (FC Members ranks, Job Board divisions) */
.portal-table .portal-group-row td {
  background: var(--bg-darker);
  padding: 0.45rem 0.75rem;
  font-family: 'Stoke', serif;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* --------------- Responsive --------------- */
@media (max-width: 1100px) {
  .division-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .dash-attention-row { flex-wrap: wrap; }
  .dash-attention-text { flex-basis: 100%; order: 2; }
  .dash-open { margin-left: auto; }
  .portal-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .portal-sidebar-rail { display: none; }
  .portal-topbar {
    display: flex;
    /* Keep the top bar pinned so it stays visible after modal saves / form
       rerenders on mobile — without this, some viewport changes (virtual
       keyboard, momentum scroll) could leave the shell scrolled with the
       topbar out of view. */
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .portal-sidebar-drawer { display: flex; flex-direction: column; }
  /* Use dynamic viewport height so the drawer matches the visible area when
     mobile browser chrome (address bar) is shown — 100vh overshoots it. */
  .portal-sidebar-drawer { height: 100dvh; }
  /* The shared sidebar body pins its footer to the bottom via min-height:100%
     and a flex:1 nav, which on the drawer (offset by the close-button header)
     forced the footer below the fold. Let the body and nav size to their
     content so the drawer itself scrolls and Log out + theme toggle stay
     reachable. */
  .portal-sidebar-drawer .portal-sidebar-body { min-height: 0; flex: 0 0 auto; }
  .portal-sidebar-drawer .sidebar-nav { flex: 0 0 auto; }
  .portal-drawer-overlay { display: block; }
  .portal-main { padding: 1rem 1rem 3rem; }
  .portal-field-row { grid-template-columns: 1fr; }
  .portal-search { min-width: 0; width: 100%; }
  .portal-card-actions { width: 100%; }
  /* Section headers with extra content (dashboard date, FC Members search +
     add button) wrap instead of overflowing the viewport. */
  .portal-main .portal-section-header { flex-wrap: wrap; }
  .dashboard-header .dashboard-date {
    flex-basis: 100%;
    margin-left: 0;
    white-space: normal;
  }
  .members-header-actions {
    flex-basis: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }
}
