:root {
  --bg-page: #ebebeb;
  --bg-subtle: #f5f5f5;
  --surface: #ffffff;
  --surface-border: #e2e8f0;
  --ink: #0f172a;
  --ink-muted: #475569;
  --ink-soft: #64748b;
  --accent: #10367d;
  --accent-hover: #0c2a61;
  --accent-soft: #74b4d9;
  --accent-soft-bg: #e8f4fa;
  --focus: #10367d;
  --sidebar-width: 17rem;
  --sidebar-collapsed: 4.75rem;
  --topbar-height: 4rem;
  --font: Roboto, system-ui, sans-serif;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 0.875rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--ink);
  line-height: 1.5;
  font-family: var(--font);
}

body.auth-layout {
  background: linear-gradient(180deg, #f3f6f9 0%, var(--bg-page) 100%);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: #fff;
  color: var(--ink);
  padding: 0.75rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Auth pages (login / forgot password) */
.auth-header {
  background: var(--surface);
  border-bottom: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
}
.auth-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.auth-layout main {
  max-width: 32rem;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}
.auth-flash {
  max-width: 32rem;
  margin: 1rem auto 0;
  padding: 0 1rem;
}

/* Split auth (login / forgot-password) — rounded card shell, no top bar */
body.auth-layout.auth-split {
  background: linear-gradient(180deg, #eef1f5 0%, #e4e7ec 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
body.auth-layout.auth-split main.auth-split-shell {
  width: 100%;
  max-width: 56rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-radius: 1.75rem;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
  background: #fff;
}
.auth-split-form-pane {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: #fff;
  padding: 1.25rem 1.35rem 1.5rem;
}
.auth-split-brand {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
  width: 100%;
  max-width: 22.5rem;
  margin: 0 auto;
}
.auth-split-brand-logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.auth-split-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  padding-top: 0.1rem;
}
.auth-split-brand-title {
  font-family: Roboto, var(--font);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.auth-split-brand-tagline {
  font-family: 'Akhand Gujarati', 'Noto Sans Gujarati', sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: #475569;
}
.auth-split-card-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem 0 0.25rem;
}
.auth-split-card {
  width: 100%;
  max-width: 22.5rem;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}
.auth-split-form-title {
  margin: 0;
  font-family: Roboto, var(--font);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.auth-split-form-help {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
  line-height: 1.4;
}
.auth-split-form {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.auth-split-form .field label {
  font-weight: 700;
  color: var(--ink);
}
.auth-split-form .field input,
.auth-split-form .field select {
  background: #e8f1fb;
  border: 1px solid #d5e4f5;
  border-radius: 0.65rem;
}
.auth-split-form .field input:focus,
.auth-split-form .field select:focus {
  background: #fff;
  border-color: var(--accent);
}
.auth-split-form-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.auth-split-marketing {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  padding: 1.75rem 1.75rem;
  color: #fff;
  background-color: #1a0a2e;
  background-image:
    radial-gradient(ellipse 80% 70% at 85% 15%, #2b59c3 0%, transparent 55%),
    radial-gradient(ellipse 90% 80% at 45% 45%, #8e1599 0%, transparent 60%),
    radial-gradient(ellipse 70% 65% at 90% 85%, #6a3de8 0%, transparent 55%),
    radial-gradient(ellipse 75% 70% at 10% 90%, #230b35 0%, transparent 50%),
    linear-gradient(145deg, #1a0b2e 0%, #2a0f45 40%, #1a0a2e 100%);
}
.auth-split-welcome {
  margin: 0 0 0.55rem;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.95;
}
.auth-split-headline {
  margin: 0 0 0.65rem;
  font-family: var(--font);
  font-size: clamp(1.15rem, 1.7vw, 1.45rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  max-width: none;
}
.auth-split-lead {
  margin: 0 0 1.15rem;
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 38rem;
  opacity: 0.92;
}
.auth-split-highlights {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 36rem;
}
.auth-split-highlight {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}
.auth-split-highlight-icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.auth-split-highlight-icon svg {
  width: 1rem;
  height: 1rem;
}
.auth-split-highlight strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.1rem;
}
.auth-split-highlight span span {
  display: block;
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.9;
}
body.auth-layout.auth-split .auth-flash {
  position: fixed;
  left: 1rem;
  right: auto;
  bottom: 1rem;
  z-index: 40;
  max-width: min(26rem, calc(50vw - 2rem));
  margin: 0;
  padding: 0;
}
@media (max-width: 960px) {
  body.auth-layout.auth-split {
    padding: 0.75rem;
    align-items: flex-start;
  }
  body.auth-layout.auth-split main.auth-split-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    border-radius: 1.25rem;
  }
  .auth-split-form-pane,
  .auth-split-marketing {
    min-height: auto;
  }
  .auth-split-marketing {
    order: 2;
    padding: 2rem 1.5rem 2.5rem;
  }
  .auth-split-headline {
    max-width: none;
  }
  .auth-split-card-wrap {
    padding: 1.25rem 0 1rem;
  }
  body.auth-layout.auth-split .auth-flash {
    max-width: calc(100vw - 2rem);
  }
}

/* Portal shell */
.portal-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-page);
}

.portal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 40;
}
.portal-overlay[hidden] { display: none; }

.portal-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.22s ease, width 0.22s ease;
  box-shadow: var(--shadow-md);
}

.portal-sidebar.is-open {
  transform: translateX(0);
}

.portal-sidebar-head {
  padding: 1.1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--surface-border);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  text-decoration: none;
  color: var(--ink);
}
.portal-brand-logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--accent-soft-bg);
}
.portal-brand-title {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
}

.portal-sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.portal-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 2.65rem;
  padding: 0.55rem 0.85rem;
  border-radius: 0.65rem;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.portal-icon {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
}
.portal-nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portal-nav-link:hover,
.portal-nav-link:focus-visible {
  background: var(--accent-soft-bg);
  color: var(--accent);
  outline: none;
}
.portal-nav-link.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.portal-nav-link.is-active:hover {
  background: var(--accent-hover);
  color: #fff;
}

.portal-sidebar-foot {
  flex-shrink: 0;
  padding: 0.85rem;
  border-top: 1px solid var(--surface-border);
}

.portal-help-triggers {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  padding: 0 0.15rem;
}
.portal-help-menu {
  position: relative;
}
.portal-help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.6rem;
  border: 1px solid var(--surface-border);
  color: var(--ink-muted);
  background: var(--bg-subtle);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.portal-help-trigger:hover,
.portal-help-trigger[aria-expanded="true"] {
  color: var(--accent);
  background: #fff;
  border-color: var(--accent-soft);
}
.portal-help-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.4rem);
  min-width: 13.5rem;
  max-width: min(18rem, 70vw);
  padding: 0.45rem;
  border-radius: 0.75rem;
  border: 1px solid var(--surface-border);
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  z-index: 40;
}
.portal-help-panel-title {
  margin: 0.15rem 0.45rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.portal-help-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.55rem;
  border-radius: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
}
.portal-help-item:hover {
  background: var(--accent-soft-bg);
  color: var(--accent);
}
.portal-social-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.portal-app-version {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.45rem 0.65rem;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1.3;
}
.portal-app-version-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}
.portal-app-version-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--ink-muted);
}
.portal-app-version-value {
  font-weight: 600;
  color: var(--ink-muted);
  font-size: 0.85rem;
}
.portal-app-version-stamp {
  font-weight: 400;
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
}
.portal-app-version-env {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}
.portal-app-version-env.is-testing {
  color: #dc2626;
}
.portal-app-version-env.is-live {
  color: #22c55e;
}
.portal-env-pulse {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  flex-shrink: 0;
  animation: portal-env-heartbeat 1.35s ease-in-out infinite;
}
.portal-app-version-env.is-testing .portal-env-pulse {
  background: #dc2626;
  box-shadow: 0 0 0.35rem rgba(220, 38, 38, 0.55);
}
.portal-app-version-env.is-live .portal-env-pulse {
  background: #22c55e;
  box-shadow: 0 0 0.35rem rgba(34, 197, 94, 0.55);
}
@keyframes portal-env-heartbeat {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.85);
  }
  14% {
    opacity: 1;
    transform: scale(1.2);
  }
  28% {
    opacity: 0.4;
    transform: scale(0.9);
  }
  42% {
    opacity: 1;
    transform: scale(1.15);
  }
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.85);
  }
}
@media (prefers-reduced-motion: reduce) {
  .portal-env-pulse {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

.portal-user-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  background: var(--bg-subtle);
  min-width: 0;
}
.portal-user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  object-fit: cover;
}
.portal-user-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.portal-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portal-user-role {
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.portal-nav-logout {
  justify-content: center;
  border: 1px solid var(--surface-border);
  background: #fff;
}

.user-menu {
  position: relative;
}
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.25rem 0.4rem 0.25rem 0.25rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 0.75rem;
  text-align: left;
  color: inherit;
}
.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
  background: var(--bg-subtle);
}
.user-menu-copy {
  display: none;
  min-width: 0;
  flex-direction: column;
}
.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  width: 16.5rem;
  background: #fff;
  border: 1px solid var(--surface-border);
  border-radius: 0.85rem;
  box-shadow: var(--shadow-md);
  padding: 0.4rem;
  z-index: 60;
}
.user-menu-head {
  padding: 0.7rem 0.75rem 0.65rem;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 0.3rem;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 0;
  background: transparent;
  border-radius: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.user-menu-item:hover {
  background: var(--bg-subtle);
}
.user-menu-item.is-danger {
  color: #b91c1c;
  margin-top: 0.25rem;
  border-top: 1px solid var(--surface-border);
  border-radius: 0 0 0.55rem 0.55rem;
}
.user-menu-item.is-danger:hover {
  background: #fef2f2;
}

.account-modal {
  border: 0;
  padding: 0;
  width: min(28rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-md);
}
.account-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.account-modal-inner {
  padding: 1.25rem 1.35rem 1.1rem;
}
.account-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 1rem;
}
.account-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.profile-hero {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.profile-hero-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}
.profile-photo {
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}
.profile-photo-fallback {
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
}
.profile-dl {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}
.profile-dl dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 600;
}
.profile-dl dd {
  margin: 0.15rem 0 0;
  font-weight: 500;
  word-break: break-word;
}

.portal-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle,
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.65rem;
  border: 1px solid var(--surface-border);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:focus-visible,
.nav-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
  position: relative;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: '';
  position: absolute;
  left: 0;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

.portal-topbar-title {
  min-width: 0;
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
}
.portal-topbar-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
}
.portal-topbar-role {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.portal-test-banner {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.55rem;
  background: linear-gradient(180deg, #fde68a 0%, #fbbf24 100%);
  border: 1px solid #d97706;
  color: #78350f;
  line-height: 1.2;
}
.portal-test-banner-title {
  font-size: clamp(0.72rem, 1.6vw, 0.9rem);
  font-weight: 800;
}
.portal-test-banner-sub {
  font-size: clamp(0.62rem, 1.3vw, 0.75rem);
  font-weight: 600;
  opacity: 0.95;
  margin-top: 0.1rem;
}

.portal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .portal-test-banner {
    padding: 0.3rem 0.45rem;
  }
  .portal-topbar-title {
    display: none;
  }
}

.portal-content {
  flex: 1 1 auto;
  padding: 1.25rem;
}

.portal-layout main {
  max-width: 80rem;
  margin: 0 auto;
}

.flash-banner-wrap {
  margin-bottom: 1rem;
}
.flash-banner-success {
  border-color: var(--accent-soft);
  background: #f8fcff;
}
.flash-banner-error {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}

/* Cards & surfaces */
.glass-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.bento-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.bento-grid .span-2 { grid-column: span 1; }
.bento-grid .span-3 { grid-column: span 1; }
@media (min-width: 768px) {
  .bento-grid .span-2 { grid-column: span 2; }
  .bento-grid .span-3 { grid-column: span 3; }
}

/* Buttons */
.btn-primary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.65rem;
  padding: 0.5rem 1rem;
  border-radius: 0.65rem;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.btn-sm {
  min-height: 2.25rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: #fff;
  border: 1px solid var(--surface-border);
  color: var(--ink);
}
.btn-ghost:hover {
  background: var(--accent-soft-bg);
  border-color: var(--accent-soft);
  color: var(--accent);
}
.btn-danger {
  background: #b91c1c;
  color: #fff;
  border: 1px solid transparent;
}

html.app-busy,
html.app-busy * {
  cursor: wait !important;
}

.btn-primary.is-busy,
.btn-danger.is-busy,
.btn-ghost.is-busy,
button.is-busy {
  opacity: 0.85;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.btn-spinner {
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.btn-ghost .btn-spinner,
.btn-ghost.is-busy .btn-spinner {
  border-color: rgba(15, 23, 42, 0.2);
  border-top-color: var(--accent);
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.queue-row-status {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--ink-muted);
  min-height: 1rem;
}

.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.btn-danger:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(16, 54, 125, 0.35);
  outline-offset: 2px;
}

.nav-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.nav-link:hover,
.nav-link:focus-visible {
  color: var(--accent-hover);
  outline: none;
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}
.field input,
.field select,
.field textarea {
  min-height: 2.65rem;
  border-radius: 0.65rem;
  border: 1px solid var(--surface-border);
  background: #fff;
  color: var(--ink);
  padding: 0.55rem 0.85rem;
  font-size: 0.925rem;
}
.field textarea { min-height: 5rem; }

.form-section {
  margin: 0;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
}
.form-section legend {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0 0.35rem;
}

/* Stats & tables */
.stat-value {
  font-family: var(--font);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}
.village-path {
  font-family: var(--font);
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}
.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.status-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 0.35rem;
  border: 1px solid var(--surface-border);
  background: var(--accent-soft-bg);
  color: var(--accent);
}
.status-pill.status-pending {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}
.status-pill.status-verified {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #0369a1;
}
.status-pill.status-approved {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.status-pill.status-rejected {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid color-mix(in srgb, var(--ink-soft) 25%, transparent);
}

.metrics-canvas {
  display: block;
  min-height: 220px;
  max-height: 420px;
}

.metrics-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}
.metrics-table th,
.metrics-table td {
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-soft) 20%, transparent);
  vertical-align: middle;
}
.metrics-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 700;
}
.metrics-table .status-pill {
  min-width: 2.25rem;
  justify-content: center;
  display: inline-flex;
}

/* Donation receipt (print + screen) */
.donation-receipt {
  border: 1px solid #1e293b;
  padding: 1.25rem 1.5rem;
  background: #fff;
  color: #0f172a;
  font-size: 0.95rem;
  line-height: 1.45;
}
.donation-receipt__brand {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.donation-receipt__logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  flex-shrink: 0;
}
.donation-receipt__org-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0;
}
.donation-receipt__org-addr {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: #334155;
}
.donation-receipt__contact {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: #334155;
  line-height: 1.4;
}
.donation-receipt__contact a {
  color: #0f172a;
  text-decoration: none;
}
.donation-receipt__contact a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.donation-receipt__legal {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid #94a3b8;
  font-size: 0.78rem;
  color: #334155;
}
.donation-receipt__legal p {
  margin: 0.15rem 0;
}
.donation-receipt__title {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: underline;
  margin: 1rem 0 0.75rem;
  letter-spacing: 0.04em;
}
.donation-receipt__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #94a3b8;
  font-size: 0.9rem;
}
.donation-receipt__meta p {
  margin: 0.2rem 0;
}
.donation-receipt__meta-right {
  text-align: right;
}
.donation-receipt__body {
  margin: 1rem 0;
}
.donation-receipt__body p {
  margin: 0.65rem 0;
  text-align: justify;
}
.donation-receipt__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 1.25rem;
}
.donation-receipt__amount-box {
  border: 2px solid #0f172a;
  padding: 0.55rem 1rem;
  font-weight: 800;
  font-size: 1.1rem;
  min-width: 8rem;
}
.donation-receipt__receiver {
  text-align: right;
  font-size: 0.9rem;
}
.donation-receipt__receiver p {
  margin: 0.15rem 0;
}
.donation-receipt__disclaimer {
  text-align: center;
  font-style: italic;
  font-size: 0.8rem;
  color: #475569;
  margin: 1.25rem 0 0;
}
@media (max-width: 640px) {
  .donation-receipt__meta {
    grid-template-columns: 1fr;
  }
  .donation-receipt__meta-right,
  .donation-receipt__receiver {
    text-align: left;
  }
}
@media print {
  @page {
    margin: 12mm;
  }
  html, body {
    background: #fff !important;
    color: #000 !important;
    height: auto !important;
    overflow: visible !important;
  }
  .skip-link,
  .print\:hidden,
  .no-print,
  .portal-sidebar,
  .portal-overlay,
  .portal-topbar,
  .portal-sidebar-foot,
  dialog,
  #portal-overlay {
    display: none !important;
  }
  .portal-shell,
  .portal-main,
  .portal-content {
    display: block !important;
    position: static !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    overflow: visible !important;
    transform: none !important;
  }
  #main {
    display: block !important;
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }
  .donation-receipt {
    display: block !important;
    visibility: visible !important;
    border-color: #000 !important;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .donation-receipt__logo {
    max-width: 72px !important;
    max-height: 72px !important;
  }
}

.req-star {
  color: #dc2626;
  font-weight: 700;
}

.member-name {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
}

.tab-btn[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
}

.queue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
}
.queue-table th,
.queue-table td {
  padding: 0.7rem 0.8rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--surface-border);
}
.queue-table th {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
  background: var(--bg-subtle);
}
.queue-table tbody tr:hover {
  background: var(--accent-soft-bg);
}
.queue-table .queue-remarks {
  min-width: 10rem;
  width: 100%;
  padding: 0.4rem 0.55rem;
  border-radius: 0.5rem;
  border: 1px solid var(--surface-border);
  background: #fff;
}

.queue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.queue-actions .btn-primary,
.queue-actions .btn-danger {
  min-height: 2rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1.2;
}

/* Officials & contacts */
.official-thumb {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  object-fit: cover;
}
.official-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .official-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .official-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.official-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.official-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.official-card-media {
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, var(--accent-soft-bg), #ebebeb);
  overflow: hidden;
}
.official-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.official-card-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: var(--font);
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
}
.official-card-body { padding: 1.1rem 1.2rem 1.25rem; }
.official-card-name {
  font-family: var(--font);
  font-size: 1.25rem;
  font-weight: 700;
}
.official-card-role {
  margin-top: 0.25rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}
.official-card-meta {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.55rem;
}
.official-card-meta dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}
.official-card-meta dd { font-weight: 600; }
.official-card-meta a {
  color: var(--ink);
  text-decoration: none;
}
.official-card-meta a:hover { color: var(--accent); }

.karobari-strip {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.karobari-chip {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--surface-border);
}
.karobari-chip-body {
  min-width: 0;
  flex: 1 1 auto;
}
.karobari-chip img,
.karobari-chip-fallback {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}
.karobari-chip-fallback {
  display: grid;
  place-items: center;
  background: var(--accent-soft-bg);
  color: var(--accent);
  font-weight: 700;
}

body.sidebar-open {
  overflow: hidden;
}

/* Desktop sidebar always visible; hamburger collapses to icons */
@media (min-width: 1024px) {
  .portal-sidebar {
    transform: none;
    box-shadow: none;
  }
  .portal-main {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.22s ease;
  }
  .portal-shell.is-collapsed .portal-sidebar {
    width: var(--sidebar-collapsed);
  }
  .portal-shell.is-collapsed .portal-main {
    margin-left: var(--sidebar-collapsed);
  }
  .portal-shell.is-collapsed .portal-brand {
    justify-content: center;
  }
  .portal-shell.is-collapsed .portal-brand-title,
  .portal-shell.is-collapsed .portal-nav-label,
  .portal-shell.is-collapsed .portal-user-meta,
  .portal-shell.is-collapsed .portal-app-version-label,
  .portal-shell.is-collapsed .portal-app-version-env,
  .portal-shell.is-collapsed .portal-app-version-stamp {
    display: none;
  }
  .portal-shell.is-collapsed .portal-help-triggers {
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 0.55rem;
    padding: 0;
  }
  .portal-shell.is-collapsed .portal-help-trigger {
    width: 1.95rem;
    height: 1.95rem;
  }
  .portal-shell.is-collapsed .portal-help-panel {
    left: calc(100% + 0.45rem);
    bottom: 0;
    min-width: 12.5rem;
  }
  .portal-shell.is-collapsed .portal-nav-link {
    justify-content: center;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }
  .portal-shell.is-collapsed .portal-user-chip {
    justify-content: center;
    padding: 0.45rem;
    background: transparent;
  }
  .portal-shell.is-collapsed .portal-app-version {
    align-items: center;
    padding: 0.35rem 0.25rem;
    text-align: center;
  }
  .portal-shell.is-collapsed .portal-app-version-value {
    font-size: 0.7rem;
  }
  .user-menu-copy {
    display: flex;
  }
  .portal-content {
    padding: 1.5rem 1.75rem 2rem;
  }
}

@media (max-width: 1023px) {
  .sidebar-toggle[aria-expanded="true"] .nav-toggle-bars,
  .nav-toggle[aria-expanded="true"] .nav-toggle-bars {
    background: transparent;
  }
  .sidebar-toggle[aria-expanded="true"] .nav-toggle-bars::before,
  .nav-toggle[aria-expanded="true"] .nav-toggle-bars::before {
    top: 0;
    transform: rotate(45deg);
  }
  .sidebar-toggle[aria-expanded="true"] .nav-toggle-bars::after,
  .nav-toggle[aria-expanded="true"] .nav-toggle-bars::after {
    top: 0;
    transform: rotate(-45deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
