/* =========================================================
   ChurchOps UI – Modern SaaS Style
   Single source of truth for ALL pages
   ========================================================= */
:root {
  /* Brand / Rubari-aligned palette */
  --color-primary: #007bff;        /* ChurchOps blue */
  --color-primary-hover: #0063cc;
  --color-primary-soft: #eef4ff;

  --color-bg-app: #f5f7fa;
  --color-bg-surface: #ffffff;
  --color-bg-sidebar: #0f172a;

  --color-border-subtle: #e5e7eb;
  --color-border-strong: #d1d5db;

  --color-text-primary: #111827;
  --color-text-muted: #6b7280;
  --color-text-on-dark: #f9fafb;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger:  #ef4444;
  --color-info:    #3b82f6;

  --radius-card: 0.75rem;
  --radius-pill: 999px;

  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.05);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui,
    -system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --font-size-base: 14px;
  --font-size-sm: 12px;
  --font-size-h1: 24px;
  --font-size-h2: 18px;
  --font-size-h3: 16px;
}

/* ---------- Resets & Base ---------- */

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

/* Desktop: sidebar + main area */
body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg-app);
  display: flex;
  min-height: 100vh;
}

/* Links */

a {
  color: #5b21ff;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Headings */

h1 {
  font-size: var(--font-size-h1);
  font-weight: 600;
  margin: 0 0 4px 0;
}

h2 {
  font-size: var(--font-size-h2);
  font-weight: 600;
  margin: 16px 0 8px 0;
}

h3 {
  font-size: var(--font-size-h3);
  font-weight: 600;
  margin: 0 0 4px 0;
}

/* ---------- Layout: content ---------- */

.page-container {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

/* Generic card wrapper for tables, etc. */
.page-card {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
  padding: 24px 24px 28px;
}

/* Spacing helpers */

.section-heading {
  margin-bottom: 4px;
}

.subtitle {
  margin: 0 0 20px;
  font-size: 13px;
  color: #6b7280;
}

/* Slightly narrower container for house fellowship view */
.container-narrow {
  max-width: 1100px;
  margin: 0 auto;
}

/* --- Nav icons (subtle inline icons) --- */

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-icon {
  font-size: 14px;
  line-height: 1;
}

.nav-label {
  line-height: 1.4;
}

/* =========================================================
   SIDEBAR NAV (DESKTOP) + MOBILE HEADER / SLIDE-OUT
   ========================================================= */

/* Mobile header (hidden on desktop) */

.mobile-header {
  display: none;
}

/* Sidebar (top-nav) – reused class so pages don't need changes */

.top-nav {
  width: 240px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
  padding: 18px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  min-height: 100vh;
  box-shadow: 4px 0 18px rgba(15, 23, 42, 0.04);

  /* ✅ Smooth “roll away” animation on desktop */
  transition: width 520ms cubic-bezier(0.22, 1, 0.36, 1),
              padding 520ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: width, padding;
  overflow: hidden; /* prevents label spill during animation */

  /* ✅ keep sidebar clickable/above admin content */
  z-index: 2000;
  pointer-events: auto;
}

.sidebar {
  width: 220px;
  background: var(--color-bg-sidebar);
  color: var(--color-text-on-dark);
  padding: 16px 12px;
}

.sidebar a {
  color: var(--color-text-on-dark);
  text-decoration: none;
}

.sidebar a:hover {
  text-decoration: none;
  opacity: 0.9;
}

.nav-item,
.nav-link {
  display: block;
  padding: 6px 10px;
  margin-bottom: 2px;
  border-radius: 6px;
  font-size: 13px;
}

.nav-item.active,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
}

/* Brand */

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

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, #5b21ff, #e11d48);
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}

/* Nav links inside sidebar */

.nav-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.nav-link {
  font-size: 13px;
  color: #6b7280;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}

.nav-link:hover {
  color: #111827;
}

.nav-link.nav-link-active,
.nav-link.active {
  color: #111827;
  border-bottom-color: #5b21ff;
  font-weight: 600;
}

/* User area at bottom of sidebar */

.nav-user {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.nav-user-name {
  font-weight: 500;
  color: #111827;
}

.nav-link-ghost {
  font-size: 13px;
  color: #6b7280;
  text-decoration: none;
}

.nav-link-ghost:hover {
  color: #111827;
  text-decoration: underline;
}

/* =========================================================
   SUBNAV (Attendance tabs, etc.)
   ========================================================= */

.subnav {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 13px;
}

.subnav-link {
  color: #6b7280;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}

.subnav-link:hover {
  color: #111827;
}

.subnav-link.active,
.subnav-link.is-active {
  color: #111827;
  border-bottom-color: #5b21ff;
  font-weight: 600;
}

/* =========================================================
   SUMMARY CARDS
   ========================================================= */

.summary-row {
  margin-top: 16px;
}

/* Summary cards: responsive auto-fit */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* Analytics row: fixed 3-col on desktop, 1-col on mobile */
.analytics-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--color-bg-surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72px;
}

.summary-card-total,
.summary-card-emphasis {
  background: #111827;
  color: #f9fafb;
  border-color: #111827;
}

.summary-card h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 6px 0;
  color: inherit;
}

.summary-card .value {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.summary-card .muted {
  font-size: var(--font-size-sm);
  color: rgba(249, 250, 251, 0.7);
}

@media (max-width: 900px) {
  .analytics-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   CARD FAMILY – unify look across app
   ============================================ */

.summary-card,
.page-card,
.settings-card,
.form-card,
.auth-card,
.page-hf-locator .panel,
.kpi-card,
.analytics-col,
.quick-link-card,
.ac-role-card {
  background: var(--color-bg-surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-soft);
}

/* Keep emphasis cards dark even in light mode */
.summary-card.summary-card-total,
.summary-card.summary-card-emphasis {
  background: #111827;
  color: #f9fafb;
  border-color: #111827;
}

.summary-card.summary-card-total .muted,
.summary-card.summary-card-emphasis .muted {
  color: rgba(249, 250, 251, 0.7);
}

/* =========================================================
   TOOLBAR & BUTTONS
   ========================================================= */

.toolbar {
  display: flex;
  gap: 10px;
  margin: 20px 0 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-subtle);
  background: #ffffff;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.btn:hover {
  background: #f3f4ff;
  border-color: #d4d4ff;
}

.btn-primary {
  background: var(--color-primary);
  border-color: transparent;
  color: #ffffff;
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

/* =========================================================
   TABLES
   ========================================================= */

.entries-table-wrapper {
  margin-top: 8px;
}

table {
  border-collapse: collapse;
  width: 100%;
}

.entries-table th,
.entries-table td {
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
}

.entries-table thead th {
  font-weight: 600;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}

.entries-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
}

.entries-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.entries-table tbody tr:hover {
  background: #eef2ff;
}

.entries-table td.numeric,
.entries-table td.num {
  text-align: right;
}

/* =========================================================
   HOUSE FELLOWSHIP LOCATOR (if/when used)
   ========================================================= */

.page-hf-locator .columns {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 24px;
  margin-top: 16px;
}

.page-hf-locator .panel {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.06);
  padding: 20px 22px;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.page-hf-locator .field-label {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 4px;
}

.page-hf-locator input[type="text"] {
  width: 100%;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 9px 14px;
  font-size: 13px;
  outline: none;
}

.page-hf-locator input[type="text"]:focus {
  border-color: #5b21ff;
  box-shadow: 0 0 0 1px rgba(91, 33, 255, 0.3);
}

/* =========================================================
   FORMS
   ========================================================= */

.form-card {
  max-width: 520px;
  margin: 32px auto;
  background: #ffffff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row select,
.form-row textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: #5b21ff;
  box-shadow: 0 0 0 1px rgba(91, 33, 255, 0.22);
}

.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

/* Footnote text */

.page-footnote {
  margin-top: 16px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* =========================================================
   LOGIN / REGISTER (AUTH)
   ========================================================= */

/* IMPORTANT FIX:
   Your auth pages (auth.py) render ONLY <div class="auth-shell">…</div>.
   But global body is display:flex (meant for sidebar layout).
   So we make .auth-shell fill the flex row, letting its grid centering work.
*/
.auth-shell {
  flex: 1;
  width: 100%;
}

/* Optional: if you ever add class="auth-page" to <body> */
body.auth-page {
  display: block;
  background: linear-gradient(135deg, #f5f7fa, #eef2ff);
  min-height: 100vh;
}

.auth-card {
  max-width: 420px;
  width: 90%;
  margin: 80px auto;
  padding: 30px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.25);
  text-align: left;
}

/* If auth-shell is used, remove big top margin */
.auth-shell .auth-card {
  width: 100%;
  margin: 0;
}

/* Titles (supports both old + new class names) */
.auth-title,
.auth-heading {
  font-size: 22px;
  font-weight: 600;
  margin: 8px 0 4px;
  color: #111827;
}

.auth-text,
.auth-subtitle {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 18px;
}

/* Optional error block */
.auth-error {
  background: #fee2e2;
  color: #991b1b;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  border: 1px solid #fecaca;
}

.auth-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.auth-bottom-text,
.auth-switch {
  margin-top: 18px;
  font-size: 13px;
  color: #4b5563;
  text-align: center;
}

/* Dark mode for auth */
body.dark-mode.auth-page {
  background: linear-gradient(135deg, #020617, #020617);
}

body.dark-mode .auth-card {
  background: #020617;
  border-color: rgba(51, 65, 85, 0.9);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
}

body.dark-mode .auth-title,
body.dark-mode .auth-heading {
  color: #e5e7eb;
}

body.dark-mode .auth-text,
body.dark-mode .auth-subtitle,
body.dark-mode .auth-bottom-text,
body.dark-mode .auth-switch {
  color: #9ca3af;
}

body.dark-mode .auth-error {
  background: rgba(127, 29, 29, 0.35);
  color: #fecaca;
  border-color: rgba(127, 29, 29, 0.6);
}

/* =========================================================
   ACCESS CONTROL / SETTINGS
   ========================================================= */

.settings-page {
  max-width: 960px;
  margin: 24px auto 40px;
}

.settings-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.settings-intro {
  margin-top: 4px;
  max-width: 620px;
}

.settings-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 18px 22px 20px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.settings-hint {
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 12px;
}

.settings-hint ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.settings-form {
  margin-top: 4px;
}

.settings-role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.settings-role-card {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 10px 12px 12px;
  background: #f9fafb;
}

.settings-role-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.settings-role-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.settings-role-sub {
  font-size: 11px;
  color: #6b7280;
}

.settings-permissions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.settings-permissions-table thead th {
  text-align: left;
  font-weight: 500;
  color: #6b7280;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(209, 213, 219, 0.8);
}

.settings-permissions-table td {
  padding: 3px 6px;
  vertical-align: middle;
}

.settings-feature-col,
.settings-feature-cell {
  width: 40%;
}

.settings-feature-cell {
  font-weight: 500;
  color: #111827;
}

.settings-perm-cell {
  text-align: center;
}

.settings-perm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #4b5563;
}

.settings-perm-toggle input[type="checkbox"] {
  width: 13px;
  height: 13px;
}

.settings-actions {
  margin-top: 14px;
  text-align: right;
}

/* Access-control page tight center */

.page-card-container {
  display: flex;
  justify-content: center;
  width: 100%;
}

.ac-cards {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 20px;
}

.ac-role-card {
  background: #ffffff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  width: 350px;
}

.ac-role-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ac-role-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.ac-role-columns {
  display: grid;
  grid-template-columns: 1fr 60px 60px;
  font-size: 12px;
  opacity: 0.6;
}

.ac-table {
  width: 100%;
  border-collapse: collapse;
}

.ac-table td {
  padding: 6px 0;
}

.ac-feature {
  font-size: 14px;
}

.ac-actions {
  margin-top: 20px;
  text-align: left;
}

.primary-button {
  background: #6a4bff;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

/* =========================================================
   RESPONSIVE (MOBILE)
   ========================================================= */

@media (max-width: 768px) {
  /* Turn off desktop flex shell */
  body {
    display: block;
  }

  /* Mobile header visible on small screens */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    z-index: 1000;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  }

  .menu-toggle {
    border: none;
    background: transparent;
    font-size: 22px;
    padding: 4px 8px;
    cursor: pointer;
  }

  .mobile-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
  }

  .mobile-title-link {
    color: #111827;
    text-decoration: none;
  }

  .mobile-title-link:hover {
    text-decoration: underline;
  }

  /* Sidebar becomes slide-out drawer */

  .top-nav {
    position: fixed;
    top: 44px;  /* just below mobile header */
    left: 0;
    bottom: 0;
    width: 230px;
    padding: 16px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    box-shadow: 2px 0 8px rgba(15, 23, 42, 0.12);
    z-index: 900;
    min-height: auto;

    /* Mobile drawer should not “animate width” */
    will-change: transform;
  }

  /* When body has menu-open, show the sidebar */
  body.menu-open .top-nav {
    transform: translateX(0);
  }

  .top-nav .nav-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .top-nav .nav-link {
    font-size: 14px;
    padding: 4px 0;
  }

  .top-nav .nav-user {
    margin-top: auto;
  }

  /* Content below header */
  .page-container {
    padding: 20px 16px 40px;
    margin-top: 56px;
  }

  .two-column {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr);
    gap: 24px;
    margin-top: 32px;
  }
}

/* =========================================================
   OVERVIEW – QUICK LINKS & COLLAPSIBLES
   ========================================================= */

/* Ensure main chart sections default to visible */
#lastServicesSection,
#quickLinksSection,
#financeSection,
#serviceSection,
#hfSection {
  display: block;
}

/* Toggle link text (Show / Hide) */
.section-toggle {
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  margin-left: 6px;
}

.section-toggle:hover {
  text-decoration: underline;
}

/* Wrapper for collapsible blocks */
.collapsible-section {
  margin-top: 10px;
  border-radius: 14px;
  background: #ffffff;
  padding: 16px 18px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

.collapsed {
  display: none !important;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  margin-bottom: 6px;
}

.section-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.quick-links-wrapper {
  margin-top: 8px;
}

.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
  margin-top: 0.8rem;
}

@media (max-width: 768px) {
  .quick-links-grid {
    grid-template-columns: 1fr;
  }
}

.quick-link-card {
  display: block;
  background: #ffffff;
  padding: 1rem 1.2rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.20);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
  transition: all 0.15s ease;
  text-decoration: none;
  color: inherit;
}

.quick-link-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

.quick-link-card h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.quick-link-card p {
  margin: 6px 0 0;
  font-size: 13px;
  color: #6b7280;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.kpi-card {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  border: 1px solid #e5e7eb;
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

.analytics-col {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  border: 1px solid #e5e7eb;
}

.simple-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.simple-list li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  border-bottom: 1px dashed #e5e7eb;
}

.simple-list li:last-child {
  border-bottom: none;
}

/* Ensure numeric columns in tables are right-aligned */
.entries-table th.numeric,
.entries-table td.numeric {
  text-align: right;
  white-space: nowrap;
}

/* Make summary tables compact */
.entries-table-wrapper {
  max-width: 640px;
}

.entries-table tbody tr td {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.entries-table-wrapper-narrow {
  max-width: 520px;
}

.entries-table-wrapper.summary-table {
  max-width: 820px;
  margin-bottom: 2rem;
}

.entries-table.summary-table tbody tr td {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.entries-table th.numeric,
.entries-table td.numeric {
  text-align: right;
  padding-right: 1.25rem;
  white-space: nowrap;
}

.entries-table thead th {
  padding-bottom: 0.65rem;
  font-weight: 600;
}

.entries-table-wrapper {
  padding-left: 1rem;
}

/* ============================================
   COLLECTIONS SUMMARY TABLE STYLING
   ============================================ */

.summary-table-wrapper {
  max-width: 900px;
  margin: 0 auto 2rem auto;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.entries-table.summary-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.entries-table.summary-table th:first-child,
.entries-table.summary-table td:first-child {
  width: 60%;
}

.entries-table.summary-table th.numeric,
.entries-table.summary-table td.numeric {
  text-align: right !important;
  padding-right: 1rem;
  white-space: nowrap;
}

.entries-table.summary-table tbody tr td {
  padding: 0.55rem 0;
}

.entries-table.summary-table thead th {
  padding-bottom: 0.75rem;
  font-weight: 600;
  color: #374151;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #007bff;
}

/* ============================================
   FOOTER – BRAND SIGNATURE
   ============================================ */

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  padding: 10px 0;
  border-top: 1px solid var(--color-border-subtle);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  z-index: 40;
}

.app-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.app-footer-left,
.app-footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.footer-brand {
  font-weight: 600;
  color: var(--color-text-primary);
}

.footer-tagline {
  color: var(--color-text-muted);
}

.footer-separator {
  opacity: 0.5;
}

.footer-powered {
  white-space: nowrap;
}

.footer-rubari {
  font-weight: 600;
  color: var(--color-primary);
}

@media (max-width: 640px) {
  .app-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

.footer-link {
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* Make room for fixed footer */
.page-container {
  padding-bottom: 90px;
}

/* ============================
   THEME: DARK MODE OVERRIDES
   ============================ */

body.dark-mode {
  background: #020617;
  color: #e5e7eb;
}

body.dark-mode .page-body,
body.dark-mode .page-container,
body.dark-mode .page-section {
  background: transparent;
  color: #e5e7eb;
}

body.dark-mode .summary-card,
body.dark-mode .page-card,
body.dark-mode .settings-card,
body.dark-mode .form-card,
body.dark-mode .auth-card,
body.dark-mode .page-hf-locator .panel,
body.dark-mode .kpi-card,
body.dark-mode .analytics-col,
body.dark-mode .quick-link-card,
body.dark-mode .ac-role-card {
  background: #020617;
  border-color: rgba(51, 65, 85, 0.9);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.5);
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4 {
  color: #e5e7eb;
}

body.dark-mode .subtitle,
body.dark-mode .muted,
body.dark-mode .scope-current {
  color: #9ca3af;
}

body.dark-mode .btn {
  background: #020617;
  color: #e5e7eb;
  border-color: rgba(51, 65, 85, 0.9);
}

body.dark-mode .btn:hover {
  background: #111827;
}

body.dark-mode .btn-primary {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #e5e7eb;
}

body.dark-mode .btn-primary:hover {
  background: #4338ca;
}

body.dark-mode .btn-ghost,
body.dark-mode .nav-link-ghost {
  background: transparent;
  color: #a5b4fc;
  border-color: transparent;
}

body.dark-mode .top-nav {
  background: #020617;
  border-bottom-color: rgba(51, 65, 85, 0.9);
}

body.dark-mode .nav-link {
  color: #e5e7eb;
}

body.dark-mode .nav-link.nav-link-active {
  color: #e5e7eb;
  border-bottom-color: #a5b4fc;
}

body.dark-mode .nav-user-name {
  color: #e5e7eb;
}

body.dark-mode .entries-table {
  background: #020617;
  border-color: rgba(51, 65, 85, 0.9);
  color: #e5e7eb;
}

body.dark-mode .entries-table th,
body.dark-mode .entries-table td {
  border-color: rgba(51, 65, 85, 0.9);
  color: #e5e7eb;
}

body.dark-mode .entries-table thead th {
  background: #020617;
}

body.dark-mode .entries-table tbody tr:nth-child(even) {
  background: #020617;
}

body.dark-mode .entries-table tbody tr:nth-child(odd) {
  background: #0b1120;
}

body.dark-mode .entries-table tbody tr:hover {
  background: #111827;
}

body.dark-mode .form-row label {
  color: #e5e7eb;
}

body.dark-mode .form-row input[type="text"],
body.dark-mode .form-row input[type="number"],
body.dark-mode .form-row input[type="date"],
body.dark-mode .form-row select,
body.dark-mode .form-row textarea {
  background: #020617;
  color: #e5e7eb;
  border-color: rgba(51, 65, 85, 0.9);
}

body.dark-mode .form-row input::placeholder,
body.dark-mode .form-row textarea::placeholder {
  color: #6b7280;
}

body.dark-mode a {
  color: #a5b4fc;
}

body.dark-mode a:hover {
  color: #c7d2fe;
}

/* ============================================
   SIDEBAR AUTO-COLLAPSE (DESKTOP)
   ============================================ */

@media (min-width: 900px) {
  #appSidebar .nav-label {
    display: inline;
    opacity: 1;
    max-width: 220px;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 260ms ease, max-width 520ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  body.nav-collapsed #appSidebar.top-nav {
    width: 72px;
    padding: 18px 10px;
  }

  body.nav-collapsed #appSidebar .nav-label {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
  }

  body.nav-collapsed #appSidebar .nav-links {
    align-items: center;
  }

  body.nav-collapsed #appSidebar .nav-link {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 10px 0;
    border-bottom: 0;
  }

  body.nav-collapsed #appSidebar .nav-user {
    align-items: center;
  }
}

/* Floating desktop menu button */
.nav-fab {
  position: fixed;
  left: 14px;
  bottom: 72px;
  z-index: 9999;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: none;
  gap: 0.5rem;
  align-items: center;
}

.nav-fab .nav-fab-text {
  font-size: 0.85rem;
  opacity: 0.75;
}

@media (min-width: 900px) {
  .nav-fab {
    display: inline-flex;
  }
}

@media (max-width: 899px) {
  .nav-fab {
    display: none !important;
  }
}

body.dark-mode .nav-fab {
  background: rgba(2, 6, 23, 0.92);
  border-color: rgba(51, 65, 85, 0.9);
  color: #e5e7eb;
}

/* ✅ Accessibility: respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .top-nav,
  #appSidebar .nav-label,
  .nav-link,
  .quick-link-card {
    transition: none !important;
  }
}

/* ============================================
   NAV GROUP / SUBMENU (Programs → children)
   ============================================ */

.nav-group {
  width: 100%;
}

.nav-group-toggle {
  width: 100%;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  padding: 6px 0;
  color: #6b7280;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-group-toggle:hover {
  color: #111827;
}

.nav-caret {
  font-size: 12px;
  opacity: 0.75;
  transform: rotate(0deg);
  transition: transform 180ms ease;
}

.nav-group.is-open .nav-caret {
  transform: rotate(90deg);
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding-left: 12px;
  border-left: 2px solid rgba(148, 163, 184, 0.20);
}

.nav-group.is-open .nav-submenu {
  display: flex;
}

.nav-submenu .nav-link {
  padding: 4px 0;
  font-size: 13px;
}

body.dark-mode .nav-group-toggle {
  color: #e5e7eb;
}

body.dark-mode .nav-group-toggle:hover {
  color: #ffffff;
}

body.dark-mode .nav-submenu {
  border-left-color: rgba(51, 65, 85, 0.9);
}

@media (min-width: 900px) {
  body.nav-collapsed #appSidebar .nav-submenu {
    display: none !important;
  }
  body.nav-collapsed #appSidebar .nav-group.is-open .nav-submenu {
    display: none !important;
  }
}

/* ============================================
   LAYOUT FIX: true centering in LIGHT + DARK
   ============================================ */

.page-body {
  flex: 1;
  width: 100%;
  display: block;
  position: relative;
  z-index: 1;
}

/* Override earlier .page-container flex: 1; */
.page-container {
  flex: none;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 90px;
}

/* Footer theme alignment */
body.dark-mode .app-footer {
  border-top-color: rgba(51, 65, 85, 0.9);
  background: rgba(2, 6, 23, 0.92);
}

body.dark-mode .app-footer-inner {
  color: #9ca3af;
}

body.dark-mode .footer-brand {
  color: #e5e7eb;
}

body.dark-mode .footer-tagline {
  color: #9ca3af;
}

/* ✅ FIX: make .muted readable in LIGHT mode */
.muted {
  color: var(--color-text-muted);
}

.summary-card-total .muted,
.summary-card-emphasis .muted {
  color: rgba(249, 250, 251, 0.7);
}

.badge { padding: 4px 8px; border-radius: 999px; font-size: 12px; }
.badge-new { background: #eef2ff; }
.badge-scheduled { background: #ecfeff; }
.badge-closed { background: #f3f4f6; }


/* ===============================
   Mobile usability patch (safe)
   =============================== */
@media (max-width: 900px) {
  .top-nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    max-width: 85vw;

    transform: translate3d(-100%, 0, 0);
    will-change: transform;

    /* IMPORTANT: disable transitions until JS marks it ready */
    transition: none;

    z-index: 1200;
    background: var(--sidebar-bg, #fff);
  }

  body.nav-ready .top-nav {
    transition: transform 220ms ease;
  }

  body.menu-open .top-nav {
    transform: translate3d(0, 0, 0);
  }

  body.menu-open {
    overflow: hidden;
  }

  .nav-fab {
    display: inline-flex;
  }
}

/* --- Mobile typography boost --- */
@media (max-width: 768px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

  /* Scale up the whole app on phones without affecting desktop */
  :root{
    --font-size-base: 16px;
    --font-size-sm: 14px;
  }

  body{
    font-size: var(--font-size-base);
    line-height: 1.5;
  }

  /* Common UI text that reads too small on iPhone */
  .subtitle,
  .nav-link,
  .nav a,
  .btn,
  .pill,
  .badge,
  .muted,
  .help,
  .hint,
  .small{
    font-size: 15px !important;
  }

  /* Buttons should be readable + tappable */
  .btn{
    padding: 10px 12px;
    min-height: 42px;
  }

  /* Tables + dense rows */
  table th, table td,
  .table th, .table td{
    font-size: 15px !important;
  }

  /* Card/section headers */
  h1{ font-size: 2.0rem; line-height: 1.15; }
  h2{ font-size: 1.35rem; line-height: 1.2; }
  h3{ font-size: 1.15rem; line-height: 1.25; }

  /* Chips/metadata labels (often 12px) */
  .card-meta,
  .meta,
  .label,
  .kpi-label,
  .stat-label{
    font-size: 14px !important;
  }
}
