:root {
  color-scheme: light;
  font: 15.5px/1.55 system-ui, "Nirmala UI", "Segoe UI", sans-serif;
  color: #1e293b;
  background: #f1f5f9;
  --ink: #0f2544;
  --accent: #17477d;
  --accent-dark: #102c50;
  --accent-soft: #eef4fb;
  --line: #dbe3ec;
  --muted: #526477;
  --surface: #f8fafc;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 37, 68, 0.06), 0 8px 24px rgba(15, 37, 68, 0.04);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[hidden] { display: none !important; }
@keyframes pageReveal {
  0% { opacity: 0; transform: translateY(14px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes refreshSweep {
  0% { transform: scaleX(0); opacity: 1; }
  75% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}
body { margin: 0; -webkit-font-smoothing: antialiased; }
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 9999;
  transform-origin: left;
  background: linear-gradient(90deg, #f59e0b, #ffffff, #10b981);
  box-shadow: 0 1px 6px rgba(245, 158, 11, 0.45);
  animation: refreshSweep 1.1s cubic-bezier(.22, .61, .36, 1) forwards;
  pointer-events: none;
}
main {
  animation: pageReveal 550ms cubic-bezier(.22, .61, .36, 1) both;
}
button, input, select, textarea { font: inherit; }

button {
  min-height: 40px;
  padding: .5rem .95rem;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease), transform 120ms var(--ease);
}
button:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
button.primary, #add {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(16, 44, 80, 0.18);
}
button.primary:hover:not(:disabled), #add:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
:focus-visible { outline: 3px solid #d97706; outline-offset: 2px; }

/* Masthead */
.masthead {
  background: linear-gradient(135deg, rgba(12, 31, 58, 0.88) 0%, rgba(20, 51, 92, 0.84) 100%);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  color: #ffffff;
  border-top: 4px solid transparent;
  border-image: linear-gradient(90deg, #ef9c41 0 33.33%, #ffffff 33.33% 66.66%, #278354 66.66% 100%) 1;
}
.masthead-inner {
  max-width: 1440px;
  margin: auto;
  padding: 1.15rem clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 2rem;
}
.brand, .header-tools, .bar { display: flex; align-items: center; gap: .8rem; }
.header-tools, .bar { flex-wrap: wrap; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.32));
}
.brand-mark .brand-logo { display: block; width: 54px; height: 54px; object-fit: contain; border-radius: 50%; }
.masthead h1 { margin: 0; font-size: clamp(1.2rem, 2.6vw, 1.6rem); line-height: 1.25; letter-spacing: -.01em; }
.masthead p { margin: .2rem 0 0; color: #cbd5e1; font-size: .86rem; }
.offline-badge {
  padding: .28rem .65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
  font-size: .78rem;
  font-weight: 500;
}

.language-pill {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(2, minmax(4.2rem, 1fr));
  padding: 3px;
  border: 1px solid #4c6c91;
  border-radius: 999px;
  background: #173459;
}
.language-thumb {
  position: absolute;
  z-index: -1;
  inset: 3px auto 3px 3px;
  width: calc((100% - 6px) / 2);
  background: #ffffff;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.language-pill.pill-animate .language-thumb { transition: transform 220ms var(--ease); }
.language-pill[data-selected="en"] .language-thumb { transform: translateX(100%); }
.language-pill label { position: relative; cursor: pointer; }
.language-pill input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.language-pill label span {
  display: grid;
  place-items: center;
  min-height: 36px;
  padding: .2rem .6rem;
  border-radius: 999px;
  color: #e2edf7;
  font-size: .85rem;
  font-weight: 650;
  transition: color 180ms var(--ease);
}
.language-pill input:checked + span { color: #0f2544; }
.language-pill input:focus-visible + span { outline: 2px solid #eab66c; outline-offset: -2px; }

/* Header Privacy Switch & Session Controls */
.privacy-pill {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border: 1px solid #4c6c91;
  border-radius: 999px;
  background: #173459;
}
.privacy-pill label { position: relative; cursor: pointer; }
.privacy-pill input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.privacy-pill label span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: .2rem .75rem;
  border-radius: 999px;
  color: #e2edf7;
  font-size: .8rem;
  font-weight: 600;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}
.privacy-pill input:checked + span {
  background: #ffffff;
  color: #0f2544;
  font-weight: 700;
}
.privacy-pill input:focus-visible + span { outline: 2px solid #eab66c; outline-offset: -2px; }
.btn-header-ghost {
  min-height: 36px;
  padding: .3rem .75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: .8rem;
  font-weight: 600;
}
button.btn-header-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.55);
  color: #ffffff;
}
.btn-end-session {
  min-height: 36px;
  padding: .3rem .85rem;
  border-radius: 999px;
  border: 1px solid rgba(254, 202, 202, 0.65);
  background: rgba(185, 28, 28, 0.85);
  color: #ffffff;
  font-size: .8rem;
  font-weight: 650;
  white-space: nowrap;
}
button.btn-end-session:hover:not(:disabled) {
  background: #991b1b;
  border-color: rgba(254, 202, 202, 0.9);
  color: #ffffff;
}
.privacy-banner {
  background: rgba(8, 20, 40, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.privacy-banner-text {
  max-width: 1440px;
  margin: 0 auto;
  padding: .38rem clamp(1rem, 3vw, 2rem);
  font-size: .78rem;
  color: #dbeafe;
}
.site-footer {
  border-top: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  margin-top: 1.5rem;
}
.site-footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem clamp(1rem, 3vw, 2rem) 1.5rem;
  display: grid;
  gap: .35rem;
  font-size: .82rem;
}
.site-footer-inner p { margin: 0; }
.profile-modal-list {
  margin: .4rem 0 .8rem;
  padding-left: 1.2rem;
  font-size: .85rem;
  color: #334155;
}
.profile-modal-note {
  font-size: .78rem;
  line-height: 1.45;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: .5rem .7rem;
  margin: .15rem 0;
}
.profile-modal-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem .75rem;
}
.profile-modal-fields .field-wide {
  grid-column: 1 / -1;
}
.profile-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .55rem;
  margin-top: .25rem;
}
.login-popup-form .profile-modal-actions .primary {
  width: auto;
  margin-top: 0;
}
@media (max-width: 540px) {
  .profile-modal-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Sticky Navigation with Sliding Pill */
.portal-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(16, 40, 72, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #284a72;
  box-shadow: 0 2px 10px rgba(15, 37, 68, 0.14);
  padding: .45rem clamp(1rem, 3vw, 2rem);
}
.portal-nav-inner {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem;
  max-width: 1440px;
  margin: auto;
  padding: .25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.nav-pill-thumb {
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  width: var(--pill-w, 0px);
  height: var(--pill-h, 0px);
  transform: translate3d(var(--pill-x, 0px), var(--pill-y, 0px), 0);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(10, 25, 47, 0.25);
  pointer-events: none;
  opacity: 0;
}
.portal-nav-inner.pill-animate .nav-pill-thumb {
  transition: transform 260ms var(--ease), width 260ms var(--ease), height 260ms var(--ease), opacity 180ms var(--ease);
}
.portal-nav-inner.pill-ready .nav-pill-thumb { opacity: 1; }
.portal-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  min-height: 36px;
  padding: .35rem .9rem;
  border-radius: 999px;
  color: #e2e8f0;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 650;
  transition: color 200ms var(--ease), background-color 160ms var(--ease);
}
.portal-nav a .nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: .9;
}
.portal-nav a:hover:not(.active), .portal-nav a:focus-visible:not(.active) {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}
.portal-nav-inner.pill-ready a.active {
  color: #0f2544;
}
.portal-nav .nav-admin-btn {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  min-height: 36px;
  padding: .35rem .95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: .85rem;
  font-weight: 650;
  white-space: nowrap;
}
.portal-nav .nav-admin-btn .nav-icon { width: 15px; height: 15px; flex-shrink: 0; }
.portal-nav .nav-admin-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
}
@keyframes loginPopIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popFromTrigger {
  0% {
    opacity: 0;
    transform: translate(var(--pop-from-x, 0px), var(--pop-from-y, -40px)) scale(0.18);
  }
  72% {
    opacity: 1;
    transform: translate(0, 0) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}
@keyframes popToTrigger {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--pop-from-x, 0px), var(--pop-from-y, -40px)) scale(0.18);
  }
}
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: overlayFadeIn 200ms ease-out both;
}
.login-overlay.is-closing {
  opacity: 0;
  transition: opacity 180ms ease-in;
}
.login-popup-card {
  position: relative;
  width: min(390px, 100%);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.65rem 1.6rem 1.5rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  animation: loginPopIn 220ms cubic-bezier(.2, .8, .2, 1) both;
}
.login-popup-card.profile-modal-card {
  width: min(540px, 100%);
  padding: 1.35rem 1.45rem 1.25rem;
  animation: popFromTrigger 320ms cubic-bezier(.22, 1, .36, 1) both;
}
.login-overlay.is-closing .login-popup-card.profile-modal-card {
  animation: popToTrigger 180ms cubic-bezier(.4, 0, 1, 1) both;
}
.login-popup-close {
  position: absolute;
  top: .85rem;
  right: .85rem;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-popup-close:hover { background: #f1f5f9; color: #0f172a; }
.login-popup-card h2 { margin: 0 0 1.1rem; font-size: 1.22rem; color: #0f2544; }
.login-popup-form { display: grid; gap: .85rem; }
.login-popup-form .primary { width: 100%; margin-top: .25rem; }
.password-field { position: relative; display: flex; align-items: center; }
.password-field input { width: 100%; padding-right: 2.5rem; }
.password-toggle {
  position: absolute; right: .4rem; top: 0; bottom: 0; margin: auto 0;
  min-height: 30px; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: #64748b;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 150ms ease, color 150ms ease;
  transform: none;
}
.password-toggle:hover:not(:disabled) { color: #0f172a; background: #f1f5f9; border-color: transparent; }
button.password-toggle:active:not(:disabled) { transform: none; }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(10, 22, 42, 0.68);
  backdrop-filter: blur(6px);
}
.admin-modal-card {
  width: min(580px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 16px;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  border-top: 4px solid transparent;
  border-image: linear-gradient(90deg, #ef9c41 0 33.33%, #ffffff 33.33% 66.66%, #278354 66.66% 100%) 1;
  box-shadow: 0 28px 70px rgba(10, 22, 42, 0.45);
}
.admin-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.35rem;
  background: linear-gradient(135deg, #0c1f3a 0%, #14335c 100%);
  color: #ffffff;
  border-bottom: 1px solid rgba(234, 179, 8, 0.35);
}
.admin-modal-head h2 { margin: 0; color: #ffffff; font-size: 1.08rem; }
.admin-modal-content { padding: 1.25rem 1.35rem 1.4rem; }
.admin-close-btn {
  min-height: 34px;
  width: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  line-height: 1;
}
.admin-close-btn:hover { background: rgba(255, 255, 255, 0.25); }

/* Main Grid */
main {
  max-width: 1440px;
  margin: auto;
  padding: clamp(1rem, 2.5vw, 1.75rem) clamp(1rem, 3vw, 2rem);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 1.65rem);
  align-items: start;
}
.editor-column, .preview-column { display: grid; gap: 1.15rem; min-width: 0; }
@media (min-width: 1024px) {
  .preview-column {
    position: sticky;
    top: 3.6rem;
    max-height: calc(100vh - 4.2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 4px;
    align-content: start;
  }
  .preview-column .preview {
    max-height: none;
    overflow: visible;
  }
}

section.card {
  min-width: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.2vw, 1.5rem);
  box-shadow: var(--shadow);
}
.autofill-card { border-top: 3px solid #0d9488; }
.toolkit-card { border-top: 3px solid #b45309; }
.toolkit-row { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.toolkit-row input, .toolkit-row select { flex: 1 1 200px; }
.toolkit-drawer { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.legal-results { display: grid; gap: .6rem; margin-top: .75rem; max-height: 260px; overflow: auto; }
.legal-item { padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.legal-item p { margin: .25rem 0 0; font-size: .84rem; }
.case-card, .card.document-card { border-top: 3px solid var(--accent); }

h2 { color: var(--ink); font-size: 1.14rem; font-weight: 700; line-height: 1.35; margin: 0 0 .85rem; }
p { margin: .5rem 0; }
small, .muted { color: var(--muted); }
.muted { font-size: .86rem; }
.bar { justify-content: space-between; margin-bottom: .75rem; }
.bar h2 { margin: 0; }
.bar .muted { margin: .2rem 0 0; }
#count {
  display: inline-block;
  margin-inline-start: .35rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: #e6f4f1;
  color: #0f5132;
  vertical-align: middle;
  font-size: .75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Form Grids & Controls */
.grid, .controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
}
.wide { grid-column: 1 / -1; }
label.field {
  display: grid;
  gap: .32rem;
  align-content: start;
  font-size: .87rem;
  font-weight: 600;
  color: #334155;
}
input:not([type=checkbox]), select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: var(--surface);
  padding: .48rem .7rem;
  color: #0f172a;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
input:not([type=checkbox]):hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:not([type=checkbox]):focus, select:focus, textarea:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 71, 125, 0.14);
}
textarea { min-height: 82px; resize: vertical; line-height: 1.45; }
input[type=checkbox] { accent-color: var(--accent); inline-size: 1rem; block-size: 1rem; flex-shrink: 0; margin-top: .15rem; }
input[type=file]::file-selector-button {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  margin-inline-end: .6rem;
  padding: .25rem .55rem;
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease);
}
input[type=file]::file-selector-button:hover { background: #f1f5f9; }

/* Autofill Section */
.autofill-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr);
  gap: .95rem;
  align-items: stretch;
}
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .35rem;
  padding: 1.1rem .85rem;
  border: 2px dashed #94a3b8;
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease), transform 150ms var(--ease);
}
.dropzone:hover, .dropzone.dragover {
  border-color: #0d9488;
  background: #f0fdfa;
}
.dropzone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.dropzone-icon { font-size: 1.65rem; line-height: 1; }
.dropzone-title { font-weight: 700; font-size: .92rem; color: var(--ink); }
.dropzone-hint { font-size: .78rem; color: var(--muted); }
.paste-box-wrap { display: flex; flex-direction: column; }
.paste-box-wrap .field { height: 100%; }
.paste-box-wrap textarea { min-height: 112px; }
.autofill-actions { margin-top: .85rem; margin-bottom: 0; }
.autofill-status {
  margin: .75rem 0 0;
  padding: .6rem .8rem;
  border-radius: 8px;
  font-size: .86rem;
  font-weight: 500;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}
.autofill-status[data-level="warn"] {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.autofill-status[data-level="error"] {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

/* Tabs & Photo Controls */
.actions { display: flex; flex-wrap: wrap; gap: .55rem; margin: .75rem 0; }
.tabs {
  padding: .45rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 1rem;
}
.person-tab {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  overflow: hidden;
}
.person-tab[data-active="true"] {
  background: #dcfce7;
  border-color: #4ade80;
  box-shadow: 0 1px 2px rgba(20, 83, 45, 0.1);
}
.tabs .person-tab-select {
  min-height: 34px;
  padding: .28rem .7rem;
  font-size: .86rem;
  overflow-wrap: anywhere;
  max-width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.tabs .person-tab-select[aria-pressed=true] {
  background: transparent;
  border-color: transparent;
  color: #14532d;
  box-shadow: none;
}
.tabs .person-tab-remove {
  min-height: 34px;
  width: 28px;
  padding: 0;
  border: 0;
  border-left: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0;
  background: transparent;
  color: #b91c1c;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: none;
}
.tabs .person-tab-remove:hover:not(:disabled) {
  background: #fee2e2;
  color: #991b1b;
  border-color: rgba(148, 163, 184, 0.35);
}
.tabs .person-tab-remove:active:not(:disabled) { transform: none; }
.photo-controls { align-items: end; margin-block: 1rem; }
.photo-controls label { flex: 1 1 210px; min-width: 0; }

/* Accordions */
details {
  margin: .65rem 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 .9rem;
  background: var(--surface);
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease);
}
details[open] { background: #ffffff; padding-bottom: .9rem; border-color: #cbd5e1; }
summary {
  cursor: pointer;
  padding: .7rem 0;
  color: var(--ink);
  font-weight: 700;
  font-size: .95rem;
  overflow-wrap: anywhere;
  user-select: none;
}
summary::marker { color: var(--accent); }
details .grid { margin-top: .35rem; }

.checks { display: grid; gap: .4rem; margin: .65rem 0 0; }
.checks label, .pack-option { display: flex; align-items: start; gap: .55rem; font-size: .88rem; cursor: pointer; }
.checks label {
  padding: .45rem .6rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid transparent;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease);
}
.checks label:hover { background: #f1f5f9; border-color: var(--line); }

.notice, .deadline { border-radius: 8px; padding: .7rem .85rem; font-size: .86rem; }
.notice { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; }
.deadline { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; white-space: pre-line; }
.deadline[data-level=late] { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Document Card & Preview */
.card.document-card { padding: 0; overflow: visible; }
.document-controls { padding: 1rem 1.25rem .85rem; }
.document-controls .controls-grid { gap: .65rem; }
.document-controls .export-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: .75rem 0 .5rem; }
.document-controls .export-actions button { padding: .45rem .5rem; font-size: .84rem; }
.btn-compact { min-height: 32px; padding: .25rem .65rem; font-size: .8rem; }
.proforma-picker {
  display: grid;
  gap: .35rem;
}
.picker-label {
  font-size: .87rem;
  font-weight: 600;
  color: #334155;
}
.combobox-wrap { position: relative; }
.combobox-trigger {
  width: 100%;
  min-height: 40px;
  padding: .48rem .75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: var(--surface);
  color: #0f172a;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  text-align: start;
}
.combobox-trigger:hover { border-color: #94a3b8; background: #ffffff; }
.combobox-caret { color: var(--muted); flex-shrink: 0; }
.combobox-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
  max-height: min(380px, 55vh);
  overflow: auto;
  overscroll-behavior: contain;
  padding: .45rem;
}
.combobox-search {
  margin-bottom: .35rem;
  min-height: 36px !important;
  padding: .35rem .65rem !important;
  font-size: .84rem;
}
.combobox-status { margin: .25rem .45rem; font-size: .78rem; }
.combobox-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.combobox-group-label {
  padding: .48rem .7rem;
  font-size: .78rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #0f2544;
  background: #eef2f7;
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  margin: .45rem 0 .2rem;
}
.combobox-group-label:first-child { margin-top: .1rem; }
.combobox-list li button {
  width: 100%;
  text-align: start;
  min-height: 34px;
  padding: .35rem .65rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-weight: 500;
  font-size: .84rem;
}
.combobox-list li button:hover, .combobox-list li button.selected {
  background: #eff6ff;
  color: var(--accent-dark);
  font-weight: 650;
}
.proforma-results-list li { display: contents; }
.proforma-results-list button {
  min-height: 30px;
  padding: .25rem .6rem;
  font-size: .78rem;
  border-radius: 999px;
}
.preview.expanded { max-height: none; }
@media (max-width: 520px) {
  .document-controls .export-actions { grid-template-columns: 1fr; }
}
.preview {
  background: #e2e8f0;
  border-top: 1px solid var(--line);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  padding: clamp(.85rem, 2vw, 1.25rem);
  max-height: 68vh;
  overflow: auto;
  overscroll-behavior: contain;
  container-type: inline-size;
  --sheet-ratio: 210 / 297;
}
.preview[data-page-size="a5"] { --sheet-ratio: 148 / 210; }
.preview[data-page-size="letter"] { --sheet-ratio: 8.5 / 11; }
.preview[data-page-size="legal"] { --sheet-ratio: 8.5 / 14; }

.paper {
  background: #ffffff;
  color: #111827;
  font-family: var(--doc-font, "Nirmala UI", Arial, sans-serif);
  padding: clamp(.9rem, 2.2vw, 1.5rem);
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
  font-size: .9rem;
}
.preview .paper { min-height: calc(100cqw / (var(--sheet-ratio))); }
.paper:last-child { margin-bottom: 0; }
.paper header { text-align: center; padding-bottom: .6rem; border-bottom: 1px solid #abbac0; }
.paper h2 { margin: .3rem 0 0; }
.paper .stamp { font-size: .78rem; color: #526069; }
.paper p, .paper td { white-space: pre-wrap; }
.paper table { width: 100%; border-collapse: collapse; margin: .65rem 0; }
.paper td { border: 1px solid #b3bfc3; padding: .38rem .45rem; vertical-align: top; }
.paper td:first-child { width: 38%; font-weight: 650; }
.paper img, #photo-preview { width: 32mm; height: 40mm; object-fit: contain; border: 1px solid #b3bfc3; border-radius: 4px; }
.identity { display: flex; gap: .7rem; align-items: start; }
.identity table { flex: 1; min-width: 0; }
.signature { margin-top: 1rem; }

.copy-strip {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
}
.copy-strip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem .75rem;
  margin-bottom: .5rem;
}
.copy-strip-title {
  font-size: .86rem;
  font-weight: 700;
  color: #0f2544;
}
.copy-note {
  margin: 0;
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.35;
}
.copy-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
}
.copy-actions button {
  text-align: center;
  justify-content: center;
  min-height: 34px;
  padding: .35rem .5rem;
  font-size: .79rem;
  font-weight: 600;
  line-height: 1.25;
}
@media (max-width: 640px) {
  .copy-actions { grid-template-columns: 1fr; }
}
.copybox { min-height: 8.5rem; margin-top: .65rem; }

/* Glassmorphic Bottom Copy Toast */
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 1.35rem;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .68rem 1.15rem;
  border-radius: 999px;
  background: rgba(15, 37, 68, 0.72);
  backdrop-filter: blur(16px) saturate(165%);
  -webkit-backdrop-filter: blur(16px) saturate(165%);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
  color: #ffffff;
  font-size: .88rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 28px) scale(.96);
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease;
}
.copy-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.copy-toast-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.85);
  color: #ffffff;
  font-size: .75rem;
  font-weight: 800;
}
#status:empty, #print-output { display: none; }
a { color: var(--accent-dark); text-underline-offset: 3px; }

main section[id] { scroll-margin-top: 4rem; }
.document-card .proforma-editor { margin: .75rem clamp(.75rem, 2vw, 1.25rem); }
.document-card .source-original { margin: .6rem 1.15rem; font-size: .84rem; }
.template-options { margin: .6rem 1.15rem; }
.template-options p { overflow-wrap: anywhere; }

/* Source Proforma Styles */
.paper.source-form { color: #111; font-family: var(--doc-font, "Nirmala UI", Mangal, Arial, sans-serif); font-size: .8rem; line-height: 1.4; }
.source-form header { border-bottom: 0; padding-bottom: .3rem; }
.source-form h2 { color: #111; font-size: 1.12em; font-weight: 750; }
.source-rule { font-weight: 700; }
.source-meta { margin-bottom: .4em; }
.source-meta p { margin: .08em 0; }
.source-form table { table-layout: fixed; margin: .3em 0 .65em; }
.source-form td { padding: .18em .4em; border: 1px solid #333; }
.source-form td:first-child { width: 5%; text-align: center; font-weight: 400; }
.source-form td:nth-child(2) { width: 28%; }
.source-form .source-photo { display: block; margin: .7em auto 0; max-width: 100%; height: auto; max-height: 40mm; object-fit: contain; }
.source-form .source-reference { margin-top: 1em; }
.diary-references { display: flex; justify-content: space-between; gap: .6rem; font-weight: 700; margin-bottom: 1.15em; }
.diary-sheet header { padding-bottom: .15em; }
.diary-meta-row { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .45em; }
.diary-meta-item { display: flex; flex: 1 1 auto; gap: .25em; align-items: baseline; min-width: 0; }
.diary-meta-value { flex: 1; border-bottom: 1px dotted #444; white-space: pre-wrap; }
.diary-sheet .diary-table { margin-top: .15em; }
.diary-table th { border: 1px solid #333; padding: .18em .4em; vertical-align: top; font-weight: 500; }
.diary-table th:first-child, .diary-sheet .diary-table td:first-child { width: 12%; text-align: start; }
.diary-table th:last-child, .diary-sheet .diary-table td:last-child { width: 13%; text-align: start; }
.diary-sheet .diary-table td:nth-child(2) { width: 75%; }
.diary-officer { margin: .35em 0 .65em; }
.diary-entry-editor { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: .75rem; }
.diary-entry-editor .field { margin-bottom: .65rem; }
.source-paragraphs { margin: .8em 0; }
.source-paragraphs > div { margin-block: .65em; }
.source-paragraphs p { margin: .15em 0; }
.source-exhibit { border-top: 1px dashed #555; padding-block: .65em; break-inside: avoid; }
.source-exhibit h3 { font-size: 1.05em; margin: .15em 0; }
.source-questioning { padding-inline-start: 1.6em; margin-block: .65em; }
.source-questioning li { margin-block: .25em; }
.source-questioning li span { white-space: pre-wrap; }
.source-questioning li strong { font-weight: 650; }
.source-form th { padding: .18em .4em; border: 1px solid #333; vertical-align: top; }
.rajasthan-office { line-height: 1.35; margin-bottom: .5em; }
.paper.rajasthan-bnss .stamp { margin-top: .35em; }
.paper.rajasthan-bnss td:first-child { width: 38%; text-align: start; font-weight: 650; }
.paper.rajasthan-bnss td:nth-child(2) { width: 62%; }
.source-letter-reference { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .25em 1em; }
.source-letter .source-letter-address { text-align: center; margin: 1.2em 0; }
.source-letter-subject { font-weight: 700; }
.source-letter .source-letter-sign { text-align: right; margin-top: 1.5em; }
.source-cover table td:first-child, .source-cover table td:nth-child(2),
.source-letter table td:first-child, .source-letter table td:nth-child(2) { width: auto; }
.source-cover table th, .source-letter table th { font-weight: 650; text-align: start; }
.source-cover header { margin-bottom: .75em; }

/* Responsive */
@media (max-width: 1023px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .preview { max-height: 70vh; }
}
@media (max-width: 640px) {
  .autofill-grid, .grid, .controls-grid { grid-template-columns: minmax(0, 1fr); }
  .identity { flex-wrap: wrap; }
  .identity table { flex-basis: 100%; }
  .document-controls .actions button, .autofill-actions button { flex: 1 1 auto; }
  .portal-nav-inner { border-radius: 16px; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Print */
@page { size: A4; margin: 14mm; }
@page bnss-a4 { size: A4; margin: 14mm; }
@page bnss-a5 { size: A5; margin: 10mm; }
@page bnss-letter { size: letter; margin: 14mm; }
@page bnss-legal { size: legal; margin: 14mm; }
@media print {
  body { background: white; }
  body > header, body > .portal-nav, body > main { display: none !important; }
  #print-output { display: block; }
  .paper { padding: 0; border: 0; border-radius: 0; box-shadow: none; margin: 0; break-after: page; font-size: 10.5pt; }
  .paper:last-child { break-after: auto; }
  .paper header { break-after: avoid; }
  .paper h2 { color: black; }
  .paper tr, .signature { break-inside: avoid; }
  .paper p { orphans: 3; widows: 3; }
  #print-output[data-page-size="a4"] .paper { page: bnss-a4; }
  #print-output[data-page-size="a5"] .paper { page: bnss-a5; }
  #print-output[data-page-size="letter"] .paper { page: bnss-letter; }
  #print-output[data-page-size="legal"] .paper { page: bnss-legal; }
  .paper.source-form { font-size: 10pt; }
  .paper .source-narrative { break-inside: auto; }
  .paper.diary-sheet .diary-table tr { break-inside: auto; }
  .diary-table thead { display: table-header-group; }
}
.workflow-sheet td:first-child { width: 37%; text-align: start; font-weight: 650; } .workflow-sheet td:nth-child(2) { width: 63%; } .source-reference { overflow-wrap: anywhere; }
.proforma-search { margin: 0; }
.proforma-search summary { padding: .45rem 0; }
#proforma-search-status { margin: .35rem 0; }
#proforma-search-status:empty, #proforma-results:empty { display: none; }
#proforma-results { list-style: none; margin: 0; padding: .25rem; max-height: 15rem; overflow: auto; }
#proforma-results li + li { margin-top: .3rem; }
#proforma-results button { width: 100%; text-align: start; }
