:root,
[data-theme="green"] {
  --bcg: #006a4e;
  --bcg-dark: #003d2e;
  --bcg-mid: #004d3a;
  --bcg-soft: #e8f3ee;
  --bcg-accent: #c9923a;
  --bcg-gold: #d4a84b;
  --bcg-accent-bright: #f4c81f;
  --bcg-red: #f42a41;
  --bcg-red-soft: #fceceb;
  --text: #10231d;
  --text-secondary: #3d524a;
  --muted: #5a6d66;
  --surface: #ffffff;
  --bg: #f0f4f2;
  --border: #dce5df;
  --border-strong: #c5d4cc;
  --on-primary: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 35, 29, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 35, 29, 0.08);
  --sidebar-bg: linear-gradient(180deg, #004334 0%, #003d2e 55%, #002820 100%);
  --sidebar-fg: rgba(255, 255, 255, 0.92);
  --sidebar-muted: rgba(255, 255, 255, 0.65);
  --sidebar-border: rgba(201, 146, 58, 0.28);
  --sidebar-active: rgba(201, 146, 58, 0.22);
  --sidebar-accent: #d4a84b;
  --login-brand-overlay: linear-gradient(165deg, rgba(0, 61, 46, 0.92), rgba(0, 106, 78, 0.78));
  --theme-meta: #003d2e;
  --focus-ring: 0 0 0 3px rgba(0, 106, 78, 0.35);
}

[data-theme="red"] {
  --bcg: #c9182b;
  --bcg-dark: #8e101c;
  --bcg-mid: #a81424;
  --bcg-soft: #fceceb;
  --bcg-accent: #c9923a;
  --bcg-gold: #d4a84b;
  --bcg-accent-bright: #f4c81f;
  --bcg-red: #f42a41;
  --bcg-red-soft: #fceceb;
  --text: #1a1214;
  --text-secondary: #4a393c;
  --muted: #6b575b;
  --surface: #ffffff;
  --bg: #f7f3f3;
  --border: #eadfdf;
  --border-strong: #d7c5c7;
  --on-primary: #ffffff;
  --shadow-sm: 0 1px 2px rgba(26, 18, 20, 0.06);
  --shadow-md: 0 8px 24px rgba(26, 18, 20, 0.08);
  --sidebar-bg: linear-gradient(180deg, #a81424 0%, #8e101c 55%, #5c0a12 100%);
  --sidebar-fg: rgba(255, 255, 255, 0.94);
  --sidebar-muted: rgba(255, 255, 255, 0.68);
  --sidebar-border: rgba(244, 200, 31, 0.28);
  --sidebar-active: rgba(244, 200, 31, 0.18);
  --sidebar-accent: #f4c81f;
  --login-brand-overlay: linear-gradient(165deg, rgba(142, 16, 28, 0.94), rgba(201, 24, 43, 0.8));
  --theme-meta: #8e101c;
  --focus-ring: 0 0 0 3px rgba(201, 24, 43, 0.35);
}

[data-theme="yellow"] {
  --bcg: #c9a016;
  --bcg-dark: #1a1810;
  --bcg-mid: #a88712;
  --bcg-soft: #fbf6e4;
  --bcg-accent: #8a7010;
  --bcg-gold: #d4a84b;
  --bcg-accent-bright: #f4c81f;
  --bcg-red: #f42a41;
  --bcg-red-soft: #fceceb;
  --text: #1a1810;
  --text-secondary: #4a4536;
  --muted: #6b6450;
  --surface: #fffcf5;
  --bg: #f7f3e8;
  --border: #e6dfcb;
  --border-strong: #d0c6a8;
  --on-primary: #1a1810;
  --shadow-sm: 0 1px 2px rgba(26, 24, 16, 0.06);
  --shadow-md: 0 8px 24px rgba(26, 24, 16, 0.08);
  --sidebar-bg: linear-gradient(180deg, #2a2618 0%, #1a1810 60%, #0f0e09 100%);
  --sidebar-fg: rgba(255, 250, 235, 0.95);
  --sidebar-muted: rgba(244, 200, 31, 0.75);
  --sidebar-border: rgba(244, 200, 31, 0.3);
  --sidebar-active: rgba(244, 200, 31, 0.16);
  --sidebar-accent: #f4c81f;
  --login-brand-overlay: linear-gradient(165deg, rgba(26, 24, 16, 0.92), rgba(168, 135, 18, 0.72));
  --theme-meta: #1a1810;
  --focus-ring: 0 0 0 3px rgba(201, 160, 22, 0.4);
}

[data-theme="white"] {
  --bcg: #006a4e;
  --bcg-dark: #1c2421;
  --bcg-mid: #2f3d38;
  --bcg-soft: #f4f6f5;
  --bcg-accent: #c9923a;
  --bcg-gold: #b8923e;
  --bcg-accent-bright: #d4a84b;
  --bcg-red: #f42a41;
  --bcg-red-soft: #fceceb;
  --text: #1c2421;
  --text-secondary: #44504c;
  --muted: #67736f;
  --surface: #ffffff;
  --bg: #fafbfa;
  --border: #e6ebe8;
  --border-strong: #cfd8d3;
  --on-primary: #ffffff;
  --shadow-sm: 0 1px 2px rgba(28, 36, 33, 0.04);
  --shadow-md: 0 8px 24px rgba(28, 36, 33, 0.06);
  --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f7f9f8 100%);
  --sidebar-fg: #1c2421;
  --sidebar-muted: #67736f;
  --sidebar-border: #e6ebe8;
  --sidebar-active: rgba(0, 106, 78, 0.08);
  --sidebar-accent: #006a4e;
  --login-brand-overlay: linear-gradient(165deg, rgba(28, 36, 33, 0.55), rgba(0, 106, 78, 0.45));
  --theme-meta: #ffffff;
  --focus-ring: 0 0 0 3px rgba(0, 106, 78, 0.28);
}

[data-theme="black"] {
  --bcg: #2d9a72;
  --bcg-dark: #e8f0ec;
  --bcg-mid: #3aaf84;
  --bcg-soft: #151c19;
  --bcg-accent: #d4a84b;
  --bcg-gold: #d4a84b;
  --bcg-accent-bright: #f4c81f;
  --bcg-red: #f42a41;
  --bcg-red-soft: #3a2024;
  --text: #e8f0ec;
  --text-secondary: #b4c4bc;
  --muted: #8a9b93;
  --surface: #121916;
  --bg: #0b1210;
  --border: #24302b;
  --border-strong: #35443d;
  --on-primary: #0b1210;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --sidebar-bg: linear-gradient(180deg, #101714 0%, #0b1210 100%);
  --sidebar-fg: rgba(232, 240, 236, 0.95);
  --sidebar-muted: rgba(180, 196, 188, 0.75);
  --sidebar-border: rgba(212, 168, 75, 0.22);
  --sidebar-active: rgba(45, 154, 114, 0.22);
  --sidebar-accent: #d4a84b;
  --login-brand-overlay: linear-gradient(165deg, rgba(11, 18, 16, 0.94), rgba(18, 40, 32, 0.88));
  --theme-meta: #0b1210;
  --focus-ring: 0 0 0 3px rgba(45, 154, 114, 0.4);
}

:root {
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --space-8: 48px;
  --sidebar-w: 280px;
  --header-h: 56px;
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: "Source Sans 3", "Noto Sans Bengali", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Cormorant Garamond", "Noto Serif Bengali", Georgia, serif;
}

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

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

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.ready .content-inner {
  animation: fadeIn 0.2s ease;
}

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

@media (prefers-reduced-motion: reduce) {
  body.ready .content-inner,
  * {
    animation: none !important;
    transition: none !important;
  }
}

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

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

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Instant-nav progress */
.nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
  background: transparent;
  opacity: 0;
}

.nav-progress.active {
  opacity: 1;
  background: linear-gradient(90deg, var(--bcg-gold), var(--bcg), var(--bcg-gold));
  background-size: 200% 100%;
  animation: navBar 0.9s ease infinite;
  transform-origin: left;
}

.nav-progress.done {
  animation: none;
  background: var(--bcg-gold);
  opacity: 0;
  transition: opacity 0.3s ease;
}

@keyframes navBar {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* —— App shell (sidebar + main) —— */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-shell.has-sidebar {
  flex-direction: row;
  align-items: stretch;
}

.app-shell.is-viewer {
  background: #1a2420;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-main.full-bleed {
  width: 100%;
}

/* Desktop aristocratic sidebar */
.sidebar-nav {
  display: none;
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  flex-direction: column;
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--sidebar-fg);
  padding: var(--space-2) var(--space-2) var(--space-5);
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: var(--space-4);
}

.sidebar-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--sidebar-accent);
}

.sidebar-brand-text .brand-title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--sidebar-fg);
}

.sidebar-brand-text .brand-subtitle {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--sidebar-accent);
  letter-spacing: 0.02em;
  font-weight: 600;
}

.sidebar-label {
  margin: 0 0 var(--space-2) var(--space-2);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-accent);
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.7rem 0.85rem;
  min-height: 44px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--sidebar-fg);
  opacity: 0.86;
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.sidebar-link:hover {
  background: var(--sidebar-active);
  opacity: 1;
}

.sidebar-link.is-active {
  background: var(--sidebar-active);
  opacity: 1;
  box-shadow: inset 3px 0 0 var(--sidebar-accent);
}

.sidebar-ico {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  opacity: 0.9;
}

.sidebar-ico svg {
  width: 18px;
  height: 18px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--sidebar-border);
  display: grid;
  gap: var(--space-3);
}

.sidebar-user-name {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--sidebar-fg);
}

.sidebar-user-role {
  display: block;
  font-size: 0.75rem;
  color: var(--sidebar-muted);
  margin-top: 2px;
}

.sidebar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--sidebar-border);
  color: var(--sidebar-fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

.sidebar-logout:hover {
  background: var(--sidebar-active);
}

/* Slim mobile PWA topbar */
.mobile-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: calc(var(--safe-top) + 10px) var(--space-4) 10px;
  min-height: calc(52px + var(--safe-top));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.mobile-brand {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--bcg-gold) 45%, var(--border));
  box-shadow: var(--shadow-sm);
}

.mobile-brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

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

.mobile-page-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--bcg-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-page-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mobile-topbar.contextual .back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--bcg-dark);
  text-decoration: none;
  background: var(--bcg-soft);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--bcg-dark);
  text-decoration: none;
  background: var(--bcg-soft);
  flex-shrink: 0;
}

.layout {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-4);
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--space-5));
}

.app-shell.no-bottom-pad .layout {
  padding-bottom: var(--space-5);
}

.app-shell.is-viewer .layout {
  max-width: none;
  padding: 0;
  padding-bottom: 0;
}

.content {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.content-inner {
  width: 100%;
}

.footer {
  display: none;
  padding: var(--space-4) var(--space-5);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}

.brand-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  display: block;
  font-size: 0.75rem;
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(16, 35, 29, 0.06);
}

.bottom-nav a,
.bottom-nav button.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--bottom-nav-h);
  padding: var(--space-2) var(--space-1);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav a.is-active,
.bottom-nav button.nav-tab.is-active {
  color: var(--bcg);
}

.bottom-nav a.is-active .nav-icon,
.bottom-nav button.nav-tab.is-active .nav-icon {
  color: var(--bcg);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
}

/* More sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 35, 29, 0.4);
  z-index: 60;
}

.more-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-4) var(--space-4) calc(var(--space-5) + var(--safe-bottom));
  box-shadow: var(--shadow-md);
  max-height: 70dvh;
  overflow-y: auto;
}

.more-sheet h2 {
  margin: 0 0 var(--space-3);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.more-sheet a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  min-height: 48px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  color: var(--text);
}

.more-sheet a:hover,
.more-sheet a:active {
  background: var(--bcg-soft);
}

.more-sheet a.danger {
  color: var(--bcg-red);
}

body.sheet-open {
  overflow: hidden;
}

/* FAB */
.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--space-4));
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 52px;
  padding: 0 var(--space-4);
  border-radius: 999px;
  background: var(--bcg);
  color: var(--on-primary);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 28px rgba(0, 106, 78, 0.35);
  border: none;
  cursor: pointer;
}

.fab:hover {
  background: var(--bcg-dark);
}

.fab-icon {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 400;
}

/* Install banner */
.install-banner {
  position: fixed;
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--space-3));
  z-index: 55;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Author `display: flex` otherwise overrides the HTML [hidden] attribute */
.install-banner[hidden],
.install-banner.is-hidden {
  display: none !important;
}

.install-banner p {
  margin: 0;
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Pull to refresh */
.ptr-indicator {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, max-height 0.2s ease, padding 0.2s ease;
}

.ptr-indicator.visible,
.ptr-indicator.refreshing {
  opacity: 1;
  transform: none;
  max-height: 40px;
  padding: var(--space-2);
}

/* —— Page primitives —— */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-header .title-group h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--bcg-dark);
}

.page-header .title-group p {
  margin: var(--space-2) 0 0;
  max-width: 540px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--bcg-soft);
  color: var(--bcg-dark);
  font-weight: 650;
  font-size: 0.8rem;
  white-space: nowrap;
}

.badge-accent {
  background: rgba(244, 200, 31, 0.25);
  color: #6b5500;
}

.badge-danger {
  background: var(--bcg-red-soft);
  color: #8a1f1f;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.panel h2 {
  margin: 0 0 var(--space-4);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--bcg-dark);
}

.panel p,
.panel li {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: grid;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
  min-height: auto;
}

.stat-card strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--bcg-dark);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.stat-card a {
  color: var(--bcg);
  font-weight: 600;
  text-decoration: none;
}

.stat-card a:hover {
  text-decoration: underline;
}

.action-list {
  display: grid;
  gap: var(--space-2);
}

.action-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  min-height: 56px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.action-row:hover {
  background: var(--bcg-soft);
  border-color: var(--border-strong);
}

.action-row-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bcg-soft);
  color: var(--bcg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.action-row strong {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
}

.action-row span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.action-row-chevron {
  margin-left: auto;
  color: var(--muted);
  opacity: 0.6;
}

/* Legacy aliases */
.action-grid {
  display: grid;
  gap: var(--space-2);
}

.action-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.action-card:hover {
  background: var(--bcg-soft);
  border-color: var(--border-strong);
}

.action-card strong {
  color: var(--bcg-dark);
  font-size: 1rem;
}

.action-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Forms */
.form-grid {
  display: grid;
  gap: var(--space-4);
}

.form-group {
  display: grid;
  gap: var(--space-2);
}

label {
  font-weight: 650;
  font-size: 0.875rem;
  color: var(--text);
  letter-spacing: 0.01em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--bcg);
  outline: none;
  box-shadow: var(--focus-ring);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.button,
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  background: var(--bcg);
  color: var(--on-primary);
  padding: 0.7rem 1.1rem;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.button:hover,
button:hover {
  background: var(--bcg-dark);
}

.button:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.button-secondary:hover {
  background: var(--bcg-soft);
  color: var(--bcg-dark);
}

.button-ghost {
  background: transparent;
  color: var(--bcg);
  border: none;
}

.button-danger {
  background: var(--bcg-red);
}

.button-block {
  width: 100%;
}

.form-actions-sticky {
  position: sticky;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
  padding: var(--space-4) 0 var(--space-2);
  margin-top: var(--space-2);
}

/* Search */
.search-tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  padding: 3px;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.search-tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 40px;
  box-shadow: none;
}

.search-tab:hover {
  background: rgba(0, 106, 78, 0.06);
  transform: none;
  box-shadow: none;
}

.search-tab.active {
  color: var(--bcg-dark);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-panel {
  display: block;
  margin-bottom: var(--space-4);
}

.search-panel.is-hidden,
.is-hidden {
  display: none !important;
}

.metadata-search-grid {
  grid-template-columns: 1fr;
  margin-bottom: var(--space-4);
}

.metadata-search-grid .form-group label {
  display: block;
}

.metadata-search-grid input {
  display: block;
  min-height: 44px;
}

.search-control {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

@media (min-width: 560px) {
  .search-control {
    grid-template-columns: 1fr auto;
  }
}

.search-results {
  display: grid;
  gap: var(--space-3);
}

.result-card,
.list-row {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s ease;
}

.result-card:hover,
.list-row:hover {
  border-color: var(--border-strong);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.result-header h3 {
  margin: 0;
  font-size: 1rem;
}

.result-card p {
  margin: 0.35rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.doc-link {
  color: var(--bcg);
  text-decoration: none;
  font-weight: 650;
}

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

/* Tables → mobile lists */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.data-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.mobile-card-list {
  display: none;
  gap: var(--space-3);
}

.mobile-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--surface);
}

.mobile-card h3 {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
}

.mobile-card dl {
  margin: 0;
  display: grid;
  gap: var(--space-1);
  font-size: 0.85rem;
}

.mobile-card dt {
  color: var(--muted);
  display: inline;
}

.mobile-card dd {
  display: inline;
  margin: 0 0 0 0.35rem;
}

@media (max-width: 719px) {
  .table-desktop {
    display: none;
  }
  .mobile-card-list {
    display: grid;
  }
}

/* Meetings */
.meeting-list {
  display: grid;
  gap: var(--space-3);
}

.meeting-card {
  display: block;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.meeting-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.meeting-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.meeting-card-header h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.meeting-card-header h3 a {
  color: var(--bcg-dark);
  text-decoration: none;
}

.meeting-card-header h3 a:hover {
  text-decoration: underline;
}

.meeting-card p {
  margin: 0.25rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.checkbox-list {
  display: grid;
  gap: var(--space-2);
  max-height: 260px;
  overflow-y: auto;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 500;
  min-height: 40px;
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--bcg);
}

/* Section tabs (meeting detail) */
.section-tabs {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-1);
  -webkit-overflow-scrolling: touch;
}

.section-tabs a {
  flex-shrink: 0;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.section-tabs a:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* Alerts */
.alert {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-weight: 600;
  font-size: 0.9rem;
}

.alert-success {
  background: rgba(22, 124, 73, 0.1);
  border: 1px solid rgba(22, 124, 73, 0.22);
  color: #0f4f2c;
}

.alert-error {
  background: rgba(178, 34, 34, 0.08);
  border: 1px solid rgba(178, 34, 34, 0.22);
  color: #8a1f1f;
}

.muted {
  color: var(--muted);
}

/* Empty / skeleton */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  background: var(--bcg-soft);
  color: var(--bcg);
  display: grid;
  place-items: center;
}

.empty-state h3 {
  margin: 0 0 var(--space-2);
  color: var(--bcg-dark);
  font-size: 1.1rem;
}

.empty-state p {
  margin: 0 0 var(--space-4);
  color: var(--muted);
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.skeleton {
  background: linear-gradient(90deg, #e8eee9 25%, #f4f7f5 50%, #e8eee9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-list {
  display: grid;
  gap: var(--space-3);
}

.skeleton-row {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  display: grid;
  gap: var(--space-2);
}

.skeleton-line {
  height: 12px;
}

.skeleton-line.short {
  height: 10px;
}

/* Upload pipeline */
.upload-flow {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #f7faf8 0%, #ffffff 100%);
}

.upload-flow-header {
  margin-bottom: var(--space-4);
}

.upload-flow-title {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
  font-weight: 700;
  color: var(--bcg-dark);
}

.upload-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.upload-steps {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

@media (min-width: 720px) {
  .upload-steps {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
  }
}

.upload-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  min-height: 72px;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.upload-step-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.upload-step-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.upload-step-body strong {
  font-size: 0.9rem;
  color: var(--text);
}

.upload-step-body span {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.upload-step.is-pending {
  opacity: 0.72;
}

.upload-step.is-active {
  border-color: rgba(0, 106, 78, 0.35);
  background: var(--bcg-soft);
  box-shadow: 0 0 0 3px rgba(0, 106, 78, 0.08);
}

.upload-step.is-active .upload-step-index {
  background: var(--bcg);
  color: #fff;
  border-color: var(--bcg);
  animation: pulseStep 1.1s ease infinite;
}

.upload-step.is-done {
  border-color: rgba(0, 106, 78, 0.28);
  background: #f3faf6;
}

.upload-step.is-done .upload-step-index {
  background: var(--bcg);
  color: #fff;
  border-color: var(--bcg);
}

.upload-flow.is-complete .upload-step.is-done .upload-step-index::after {
  content: none;
}

@keyframes pulseStep {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.progress-wrap {
  display: grid;
  gap: var(--space-2);
}

.progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--bcg), var(--bcg-gold));
  transition: width 0.45s ease;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  padding-right: 0.55rem;
  min-width: 0;
}

.progress-fill.is-complete {
  width: 100% !important;
  background: linear-gradient(90deg, var(--bcg-dark), var(--bcg));
}

.progress-fill.indeterminate {
  width: 40% !important;
  animation: indeterminate 1.1s ease infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(280%); }
}

.progress-hint {
  margin: 0;
  font-size: 0.82rem;
}

.upload-state {
  margin-bottom: var(--space-4);
  display: none;
}

.upload-state.is-active {
  display: block;
}

.form-section {
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.form-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: var(--space-3);
}

/* Viewer immersive */
.viewer-chrome .page-header {
  display: none;
}

body.viewer-chrome,
body.viewer-mode {
  overflow: hidden;
}

.app-shell.is-viewer .layout,
.app-shell.is-viewer .content,
.app-shell.is-viewer .content-inner {
  padding: 0;
  margin: 0;
  max-width: none;
}

.viewer-panel {
  padding: 0;
  margin: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #121a17;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.viewer-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem 0.85rem;
  padding: calc(var(--safe-top, 0px) + 0.65rem) 0.85rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(20, 32, 28, 0.94);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.viewer-title-block {
  min-width: 0;
}

.viewer-doc-title {
  color: #f3f7f4;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-panel .secure-note {
  color: rgba(200, 220, 210, 0.7);
  font-size: 0.72rem;
  margin-top: 0.1rem;
}

.viewer-status {
  display: none;
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

.viewer-page-info {
  min-width: 3.4rem;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.78);
  font-variant-numeric: tabular-nums;
}

.viewer-sep {
  width: 1px;
  height: 1.1rem;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 0.15rem;
}

.viewer-controls button,
.viewer-controls a,
.viewer-toolbar .button {
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  min-height: 38px;
  min-width: 38px;
  white-space: nowrap;
}

.viewer-toolbar .button-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.viewer-toolbar .button-secondary:disabled {
  opacity: 0.35;
}

.pdf-viewer-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(ellipse at top, rgba(55, 90, 72, 0.22), transparent 55%),
    #121a17;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.pdf-container,
#pdf-container {
  width: 100%;
  overflow: auto;
  padding: 0.85rem;
  -webkit-overflow-scrolling: touch;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#pdf-container canvas {
  display: block;
  margin: 0 auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  max-width: none;
  height: auto;
  border-radius: 2px;
}

.viewer-panel,
.pdf-viewer-frame {
  user-select: none;
}

.page-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.pdf-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 0.14;
  color: #0a2a1f;
  font-size: clamp(0.7rem, 2.2vw, 0.95rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 1rem;
  transform: rotate(-24deg);
  white-space: pre-wrap;
  line-height: 1.35;
}

.viewer-loading,
.viewer-error {
  margin: 3rem auto;
  max-width: 26rem;
  text-align: center;
  color: rgba(236, 244, 239, 0.88);
  padding: 1.5rem;
}

.viewer-loading p {
  margin: 0.85rem 0 0;
  color: rgba(220, 232, 226, 0.75);
}

.viewer-spinner {
  width: 2rem;
  height: 2rem;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #8fd6b5;
  animation: viewer-spin 0.8s linear infinite;
}

@keyframes viewer-spin {
  to {
    transform: rotate(360deg);
  }
}

.viewer-error {
  color: #ffc9c9;
  background: rgba(80, 24, 24, 0.35);
  border: 1px solid rgba(255, 140, 140, 0.25);
  border-radius: 12px;
}

.viewer-error p {
  margin: 0.6rem 0 1rem;
  color: rgba(255, 220, 220, 0.85);
}

.viewer-seal-footer {
  margin: 0;
  padding: 0.45rem 0.85rem calc(0.45rem + var(--safe-bottom, 0px));
  font-size: 0.68rem;
  color: rgba(210, 225, 218, 0.55);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: #0e1512;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 820px) {
  .viewer-toolbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .viewer-controls {
    grid-column: 1 / -1;
    justify-content: space-between;
    overflow-x: auto;
    padding-bottom: 0.15rem;
  }

  .viewer-download {
    margin-left: auto;
  }

  .viewer-sep {
    display: none;
  }
}

@media (max-width: 520px) {
  .viewer-back {
    padding-inline: 0.55rem;
  }

  .viewer-doc-title {
    font-size: 0.82rem;
  }

  .pdf-container,
  #pdf-container {
    padding: 0.5rem;
  }
}

/* Signature */
.sig-wrap {
  display: grid;
  gap: var(--space-3);
}

#sig-pad {
  width: 100%;
  max-width: 100%;
  height: 160px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  touch-action: none;
  background: #fff;
}

.sig-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.attendance-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

/* Login */
body.auth-page {
  background: var(--bg);
}

body.auth-page .app-shell {
  min-height: 100dvh;
}

body.auth-page .sidebar-nav,
body.auth-page .mobile-topbar,
body.auth-page .bottom-nav,
body.auth-page .footer {
  display: none !important;
}

body.auth-page .app-shell.has-sidebar {
  flex-direction: column;
}

body.auth-page .layout {
  padding: 0;
  max-width: none;
  padding-bottom: 0;
}

body.auth-page .content-inner {
  padding: 0;
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.login-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: clamp(200px, 34vh, 320px);
  padding: var(--space-5);
  color: #fff;
  overflow: hidden;
  isolation: isolate;
  background: var(--bcg-dark);
  border-bottom: 1px solid rgba(212, 168, 75, 0.22);
}

.login-brand-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% 42%;
  z-index: 0;
  transform: scale(1.02);
  filter: brightness(1.08) contrast(1.06) saturate(1.05);
}

.login-brand-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  /* Keep brand text readable without washing out the photo */
  background:
    linear-gradient(180deg, rgba(8, 16, 14, 0.12) 0%, rgba(8, 16, 14, 0.05) 42%, rgba(8, 16, 14, 0.72) 100%),
    linear-gradient(90deg, rgba(6, 14, 12, 0.28) 0%, rgba(6, 14, 12, 0.08) 38%, transparent 68%);
  opacity: 1;
  mix-blend-mode: normal;
}

.login-brand-stack {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: 440px;
}

.login-brand-inner {
  position: relative;
  z-index: 3;
  max-width: 440px;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.55),
    0 8px 28px rgba(0, 0, 0, 0.45);
}

.login-brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #fff;
  border-radius: 14px;
  padding: 5px;
  margin-bottom: var(--space-3);
  box-shadow: 0 0 0 1px rgba(212, 168, 75, 0.45), 0 10px 24px rgba(0, 0, 0, 0.28);
}

.login-brand-panel .brand-wordmark {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5.5vw, 2.75rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #fff;
}

.login-brand-panel .brand-tagline {
  margin: 0;
  max-width: 340px;
  font-size: 0.98rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
}

.login-brand-footer {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
}

.login-brand-credit {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

.login-brand-credit a {
  color: #f0d9a0;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.06em;
}

.login-brand-credit a:hover,
.login-brand-credit a:focus-visible {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.login-brand-credit-link {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.login-brand-credit-link:hover,
.login-brand-credit-link:focus-visible {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-4) calc(var(--space-6) + var(--safe-bottom));
  background:
    radial-gradient(ellipse at 80% 0%, color-mix(in srgb, var(--bcg) 8%, transparent), transparent 45%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: clamp(1.35rem, 3vw, 2.15rem);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  animation: authCardIn 0.45s ease both;
}

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

.auth-card h1 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--bcg-dark);
}

.auth-card > .auth-lead {
  margin: 0 0 var(--space-5);
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.98rem;
}

.auth-card .brand-splash {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.auth-card .brand-splash img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 12px;
  background: var(--bcg-soft);
  padding: 4px;
}

.auth-card .brand-splash strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--bcg-dark);
}

.auth-card .brand-splash span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.auth-card .form-group input:focus-visible {
  border-color: var(--bcg);
}

.auth-card .button-block.is-loading {
  opacity: 0.85;
  cursor: wait;
}

.auth-card .button-block .login-submit-busy {
  display: none;
}

.auth-card .button-block.is-loading .login-submit-busy {
  display: inline;
}

.auth-card .button-block.is-loading .login-submit-label {
  display: none;
}

/* Theme picker */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
}

.theme-option {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: left;
  cursor: pointer;
  min-height: 96px;
  display: grid;
  gap: var(--space-2);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.theme-option:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.theme-option.is-active {
  border-color: var(--bcg);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bcg) 25%, transparent);
}

.theme-swatch {
  display: flex;
  gap: 4px;
  height: 18px;
}

.theme-swatch span {
  flex: 1;
  border-radius: 4px;
}

.theme-option strong {
  font-size: 0.95rem;
  color: var(--text);
}

.theme-option span.theme-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.search-lang-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.lang-toggle button {
  border: none;
  background: transparent;
  padding: 0.45rem 0.9rem;
  min-height: 40px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.lang-toggle button.is-active {
  background: var(--bcg);
  color: var(--on-primary);
}

.search-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.result-why {
  margin: 0.35rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #1f6f54) 16%, transparent);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
}

.result-snippet {
  margin: 0.35rem 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}

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

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.field-error {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: #b42318;
  font-weight: 600;
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
  border-color: #f04438;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.12);
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.inline-form {
  display: inline;
  margin: 0;
}

.danger-action {
  color: #b42318 !important;
  border-color: rgba(180, 35, 24, 0.35) !important;
}

.user-edit-row td {
  background: color-mix(in srgb, var(--surface, #fff) 92%, #1f6f54 8%);
  padding: 1rem !important;
}

.user-edit-form {
  margin: 0;
}

.form-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.push-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 0.75rem 0 0.35rem;
}

@media (max-width: 720px) {
  .result-card .result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .result-download {
    margin-left: 0;
    margin-top: 0.35rem;
    display: inline-flex;
  }
}

.page-header .title-group h1 {
  font-family: var(--font-display);
  font-weight: 600;
}

.secure-note {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Desktop layout */
@media (min-width: 900px) {
  .sidebar-nav {
    display: flex;
  }

  .mobile-topbar,
  .bottom-nav,
  .fab,
  .install-banner {
    display: none !important;
  }

  .footer {
    display: block;
  }

  .layout {
    padding: var(--space-6) var(--space-6);
    padding-bottom: var(--space-6);
    max-width: 1080px;
  }

  .app-shell.has-sidebar .layout {
    margin: 0;
    max-width: none;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .metadata-search-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .form-actions-sticky {
    position: static;
    background: none;
    padding: 0;
  }

  .login-shell {
    grid-template-columns: minmax(0, 1.12fr) minmax(380px, 0.88fr);
    min-height: 100dvh;
  }

  .login-brand-panel {
    min-height: 100dvh;
    padding: var(--space-8);
    border-bottom: none;
    border-right: 1px solid rgba(212, 168, 75, 0.22);
  }

  .login-brand-photo {
    object-position: 48% 40%;
    z-index: 0;
    filter: brightness(1.12) contrast(1.08) saturate(1.08);
  }

  .login-brand-scrim {
    /* Desktop: lighter mid-panel so the boardroom image stays visible */
    background:
      linear-gradient(105deg, rgba(6, 14, 12, 0.28) 0%, rgba(6, 14, 12, 0.08) 36%, rgba(6, 14, 12, 0.02) 58%, rgba(6, 14, 12, 0.1) 100%),
      linear-gradient(180deg, rgba(6, 14, 12, 0.08) 0%, transparent 28%, rgba(6, 14, 12, 0.35) 72%, rgba(6, 14, 12, 0.78) 100%),
      color-mix(in srgb, var(--bcg-dark) 12%, transparent);
    opacity: 1;
  }

  .login-brand-stack {
    max-width: 460px;
    gap: var(--space-5);
    padding: var(--space-4) var(--space-4) var(--space-3);
    margin: 0 calc(var(--space-4) * -1) calc(var(--space-3) * -1);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, transparent 0%, rgba(4, 10, 8, 0.42) 45%, rgba(4, 10, 8, 0.62) 100%);
  }

  .login-brand-inner {
    z-index: 3;
    padding: 0;
    margin: 0;
    background: none;
  }

  .login-brand-footer {
    padding-top: var(--space-4);
  }

  .login-brand-credit {
    font-size: 0.8rem;
  }

  .login-brand-credit-link {
    font-size: 0.88rem;
  }

  .login-brand-logo {
    width: 72px;
    height: 72px;
    margin-bottom: var(--space-4);
  }

  .login-brand-panel .brand-wordmark {
    font-size: clamp(2.4rem, 3.4vw, 3.35rem);
  }

  .login-brand-panel .brand-tagline {
    font-size: 1.05rem;
    max-width: 360px;
  }

  .login-form-panel {
    padding: var(--space-7) var(--space-6);
  }

  .fab {
    bottom: var(--space-5);
  }
}

@media (min-width: 768px) and (max-width: 899px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .metadata-search-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .form-actions-sticky {
    position: static;
    background: none;
    padding: 0;
  }

  .login-shell {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 100dvh;
  }

  .login-brand-panel {
    min-height: 100dvh;
    padding: var(--space-6);
    border-bottom: none;
    border-right: 1px solid rgba(212, 168, 75, 0.22);
  }

  .login-brand-photo {
    object-position: 55% 40%;
    filter: brightness(1.1) contrast(1.06) saturate(1.06);
  }

  .login-brand-scrim {
    background:
      linear-gradient(105deg, rgba(6, 14, 12, 0.32) 0%, rgba(6, 14, 12, 0.1) 40%, rgba(6, 14, 12, 0.04) 100%),
      linear-gradient(180deg, rgba(6, 14, 12, 0.1) 0%, transparent 30%, rgba(6, 14, 12, 0.4) 74%, rgba(6, 14, 12, 0.78) 100%);
  }

  .login-brand-stack {
    gap: var(--space-4);
    padding: var(--space-3);
    margin: 0 calc(var(--space-3) * -1) calc(var(--space-2) * -1);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, transparent 0%, rgba(4, 10, 8, 0.4) 50%, rgba(4, 10, 8, 0.58) 100%);
  }

  .login-brand-inner {
    z-index: 3;
    padding: 0;
    margin: 0;
    background: none;
  }

  .login-brand-footer {
    padding-top: var(--space-3);
  }

  .login-form-panel {
    padding: var(--space-5);
  }
}

@media (max-width: 899px) {
  .app-shell.has-sidebar {
    flex-direction: column;
  }
}

@media (max-width: 767px) {
  .page-header .badge {
    display: none;
  }

  .panel {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .login-brand-panel {
    min-height: clamp(180px, 30vh, 260px);
    padding: var(--space-4) var(--space-4) var(--space-5);
  }

  .login-brand-photo {
    object-position: 70% 35%;
    filter: brightness(1.05) contrast(1.04) saturate(1.03);
  }

  .login-brand-scrim {
    background:
      linear-gradient(180deg, rgba(8, 16, 14, 0.14) 0%, rgba(8, 16, 14, 0.08) 35%, rgba(8, 16, 14, 0.78) 100%),
      linear-gradient(90deg, rgba(6, 14, 12, 0.28) 0%, transparent 55%);
  }

  .login-brand-stack {
    max-width: none;
    gap: var(--space-3);
    background: none;
    padding: 0;
    margin: 0;
  }

  .login-brand-inner {
    background: none;
    padding: 0;
    margin: 0;
  }

  .login-brand-footer {
    gap: 0.25rem 0.65rem;
    padding-top: var(--space-2);
  }

  .login-brand-credit {
    font-size: 0.7rem;
  }

  .login-brand-credit-link {
    font-size: 0.76rem;
  }

  .login-form-panel {
    align-items: flex-start;
    padding-top: var(--space-5);
  }

  .auth-card {
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    max-width: none;
    animation: none;
  }

  .auth-card .brand-splash {
    display: none;
  }

  .auth-card h1 {
    font-size: 1.75rem;
  }

  .auth-card .form-group input,
  .auth-card .button-block {
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card {
    animation: none;
  }
}
