/* -------------------------------------------------------------
 * IDP Stylesheet
 * Dark (default) + Light theme design system
 * ------------------------------------------------------------- */

/* Design Tokens & Theme Variables — Dark mode (default) */
:root,
html[data-theme="dark"] {
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Harmonious Dark HSL Color Palette */
  --bg-primary: hsl(224, 71%, 4%);
  --bg-secondary: hsl(223, 47%, 7%);
  --bg-glass: hsla(222, 47%, 11%, 0.65);
  --bg-glass-active: hsla(222, 47%, 18%, 0.85);
  --border-glass: hsla(217, 30%, 20%, 0.5);
  --border-glass-glow: hsla(190, 90%, 50%, 0.3);
  --surface-soft: hsla(220, 30%, 15%, 0.6);
  --surface-soft-2: hsla(220, 20%, 12%, 0.6);
  --surface-soft-3: hsla(220, 40%, 6%, 0.5);
  --surface-row: hsla(220, 40%, 6%, 0.15);
  --surface-header: hsla(220, 20%, 10%, 0.9);
  --shadow-elevated: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --orb-opacity: 0.45;
  
  /* Text colors */
  --text-main: hsl(210, 40%, 98%);
  --text-muted: hsl(215, 20%, 65%);
  --text-dark: hsl(220, 40%, 10%);
  
  /* Glow/Neon Accents */
  --accent-cyan: hsl(190, 90%, 50%);
  --accent-cyan-glow: hsla(190, 90%, 50%, 0.45);
  --accent-purple: hsl(270, 90%, 65%);
  --accent-purple-glow: hsla(270, 90%, 65%, 0.4);
  --accent-green: hsl(145, 80%, 48%);
  --accent-green-glow: hsla(145, 80%, 48%, 0.35);
  --accent-amber: hsl(40, 95%, 55%);
  --accent-amber-glow: hsla(40, 95%, 55%, 0.35);
  --accent-red: hsl(0, 85%, 60%);
  
  /* Core animations specs */
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-fast: all 0.15s ease;
}

/* Light mode tokens */
html[data-theme="light"] {
  --bg-primary: hsl(210, 28%, 97%);
  --bg-secondary: hsl(210, 24%, 94%);
  --bg-glass: hsla(0, 0%, 100%, 0.88);
  --bg-glass-active: hsla(0, 0%, 100%, 0.96);
  --border-glass: hsla(214, 22%, 82%, 0.9);
  --border-glass-glow: hsla(192, 70%, 36%, 0.28);
  --surface-soft: hsla(210, 25%, 94%, 0.95);
  --surface-soft-2: hsla(210, 22%, 92%, 0.95);
  --surface-soft-3: hsla(210, 20%, 96%, 0.9);
  --surface-row: hsla(210, 30%, 98%, 0.7);
  /* Clearly grey vs the near-white rows so header rows stand out */
  --surface-header: hsla(210, 14%, 85%, 0.98);
  --shadow-elevated: 0 8px 28px 0 rgba(30, 50, 80, 0.08);
  --orb-opacity: 0.18;

  --text-main: hsl(222, 32%, 16%);
  --text-muted: hsl(215, 14%, 40%);
  --text-dark: hsl(0, 0%, 100%);

  --accent-cyan: hsl(192, 78%, 32%);
  --accent-cyan-glow: hsla(192, 78%, 32%, 0.28);
  --accent-purple: hsl(248, 42%, 42%);
  --accent-purple-glow: hsla(248, 42%, 42%, 0.22);
  --accent-green: hsl(152, 55%, 32%);
  --accent-green-glow: hsla(152, 55%, 32%, 0.22);
  --accent-amber: hsl(36, 85%, 38%);
  --accent-amber-glow: hsla(36, 85%, 38%, 0.22);
  --accent-red: hsl(0, 72%, 46%);
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Background Ambient Orbs */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  z-index: 0;
  opacity: var(--orb-opacity);
  pointer-events: none;
}
.orb-1 {
  background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%);
  width: 500px;
  height: 500px;
  top: -10%;
  left: 5%;
  animation: floatOrb1 25s infinite alternate ease-in-out;
}
.orb-2 {
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
  width: 600px;
  height: 600px;
  bottom: -15%;
  right: 5%;
  animation: floatOrb2 30s infinite alternate ease-in-out;
}
.orb-3 {
  background: radial-gradient(circle, var(--accent-amber) 0%, transparent 70%);
  width: 400px;
  height: 400px;
  top: 30%;
  right: 25%;
  opacity: 0.25;
}

@keyframes floatOrb1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.1); }
}
@keyframes floatOrb2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-80px, -30px) scale(0.9); }
}

/* Application Wrapper */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  position: relative;
  z-index: 1;
  padding: 1.5rem;
  /* No max-width — fills the viewport so zoom-out doesn't leave empty side gutters */
  margin: 0 auto;
  box-sizing: border-box;
}

/* Header Component */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-elevated);
  position: relative;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.header-logo:hover {
  opacity: 0.82;
}

.logo-icon {
  width: 44px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  background: transparent;
  box-shadow: none;
}

.logo-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.logo-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  background: linear-gradient(to right, var(--text-main), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-soft);
  padding: 0.4rem 0.8rem;
  border-radius: 30px;
  border: 1px solid var(--border-glass);
}

.pulse {
  width: 8px;
  height: 8px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-green);
  animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(0.95); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.5; }
}

.status-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.active-doc-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: hsla(190, 90%, 50%, 0.1);
  border: 1px solid var(--accent-cyan-glow);
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  color: var(--accent-cyan);
  font-size: 0.85rem;
  font-weight: 600;
  max-width: min(360px, 42vw);
  min-width: 0;
}

.active-doc-badge i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.active-doc-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Layout Grid Panels */
.app-main {
  display: grid;
  grid-template-columns: 460px minmax(0, 1fr);
  gap: 1.5rem;
  flex: 1;
  min-height: 0; /* Important to keep content within window bounds and allow scrolling */
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 0.35rem;
  align-self: stretch;
}

/* Keep left cards full size — scroll the panel instead of shrinking them */
.left-panel > * {
  flex-shrink: 0;
}

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* Glassmorphic Premium Card */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.glass-card .card-header {
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

.accent-icon {
  color: var(--accent-cyan);
  width: 20px;
  height: 20px;
}

.badge {
  background: hsla(270, 90%, 65%, 0.15);
  border: 1px solid var(--accent-purple-glow);
  color: var(--accent-purple);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Keep file input activatable via <label for> (display:none breaks that in some browsers) */
.file-input-hidden {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  z-index: 2500;
}

/* Upload Card Zone */
.upload-card {
  padding: 1.1rem 1rem 0;
  text-align: center;
  cursor: pointer;
  border: 2px dashed var(--border-glass);
  transition: var(--transition-smooth);
}

/* Compact processing state: hide idle upload UI so Settings moves up */
.upload-card.is-processing,
.upload-card:has(.progress-overlay.active) {
  padding: 1rem 1.25rem 1.1rem;
  cursor: default;
  min-height: 160px;
  border-color: var(--accent-cyan);
  background: hsla(190, 90%, 50%, 0.04);
}

.upload-card.is-processing .upload-content,
.upload-card.is-processing .page-range-row,
.upload-card:has(.progress-overlay.active) .upload-content,
.upload-card:has(.progress-overlay.active) .page-range-row {
  display: none;
}

.upload-card:hover, .upload-card.dragover {
  border-color: var(--accent-cyan);
  background: hsla(190, 90%, 50%, 0.03);
  box-shadow: inset 0 0 20px hsla(190, 90%, 50%, 0.05), 0 0 15px hsla(190, 90%, 50%, 0.1);
}

.upload-content {
  padding-bottom: 0.5rem;
}

.upload-icon-wrapper {
  background: hsla(220, 30%, 15%, 0.5);
  border: 1px solid var(--border-glass);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.65rem;
  transition: var(--transition-smooth);
}

.upload-card:hover .upload-icon-wrapper {
  transform: translateY(-2px);
  border-color: var(--accent-cyan-glow);
  box-shadow: 0 0 15px var(--accent-cyan-glow);
  color: var(--accent-cyan);
}

.upload-icon {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.upload-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.upload-subtext {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0;
  line-height: 1.4;
}

.browse-link {
  color: var(--accent-cyan);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  display: inline;
}

/* Optional PDF Page Range Selector */
.page-range-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 0.35rem 0.9rem;
  border-top: 1px solid var(--border-glass);
  cursor: default;
}

.page-range-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
}

.page-range-field label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.page-range-field input {
  width: 90px;
  text-align: center;
  padding: 0.45rem;
}

.page-range-sep {
  color: var(--text-muted);
  padding-bottom: 0.5rem;
}

/* Upload Progress Overlay */
/* Floating processing card — opens at page center; drag handle moves it */
.progress-overlay {
  display: none; /* must not sit invisible over the upload UI — children would steal clicks */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}

.progress-overlay.active {
  display: flex;
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(430px, calc(100vw - 2rem));
  height: auto;
  min-height: 0;
  padding: 0 1.2rem 1.1rem;
  background: var(--bg-glass-active);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass-glow);
  border-radius: 14px;
  box-shadow: var(--shadow-elevated);
  z-index: 120;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.progress-overlay.active.is-dragging {
  user-select: none;
  cursor: grabbing;
}

.progress-drag-handle {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0 -1.2rem 0.85rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border-glass);
  border-radius: 14px 14px 0 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: grab;
  touch-action: none;
  background: hsla(210, 20%, 50%, 0.06);
}

.progress-drag-handle:active {
  cursor: grabbing;
}

.progress-drag-grip {
  width: 28px;
  height: 4px;
  border-radius: 99px;
  background: var(--border-glass);
  box-shadow: 0 5px 0 var(--border-glass);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-bottom: 0.65rem;
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.progress-overlay h4 {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.3;
  text-align: center;
}

.progress-bar-container {
  display: none !important;
}

.progress-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 340px;
  text-align: center;
  margin: 0.2rem 0 0;
}

.progress-overlay.active #cancel-extract-btn {
  margin-top: 0.85rem !important;
  padding: 0.4rem 1rem !important;
}

/* Cognitive AI Copilot Chat */
.search-card {
  flex: 0 0 auto;
  min-height: 320px;
  height: 360px;
}

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: hsla(220, 40%, 6%, 0.3);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chat-message {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  animation: fadeIn 0.4s ease forwards;
}

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

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-message.assistant .msg-avatar {
  background: hsla(270, 90%, 65%, 0.15);
  border: 1px solid var(--accent-purple-glow);
  color: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple-glow);
}

.chat-message.user .msg-avatar {
  background: hsla(190, 90%, 50%, 0.15);
  border: 1px solid var(--accent-cyan-glow);
  color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.msg-avatar i {
  width: 18px;
  height: 18px;
}

.msg-content {
  background: hsla(220, 30%, 15%, 0.4);
  border: 1px solid var(--border-glass);
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  max-width: 85%;
  font-size: 0.92rem;
}

.chat-message.user .msg-content {
  background: hsla(220, 20%, 20%, 0.5);
}

.chat-message.assistant .msg-content p {
  margin-bottom: 0.75rem;
}

.chat-message.assistant .msg-content p:last-child {
  margin-bottom: 0;
}

.msg-content strong {
  color: var(--accent-cyan);
}

/* Chat Highlight Excerpt & Filter Button styling */
.msg-excerpt {
  background: hsla(220, 40%, 6%, 0.5);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
  margin: 0.6rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: hsla(215, 10%, 45%, 0.8);
}

.msg-meta .page-ref {
  background: hsla(190, 90%, 50%, 0.15);
  color: var(--accent-cyan);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: inherit;
}

.msg-meta .page-ref.page-ref-btn {
  cursor: pointer;
  transition: var(--transition-fast);
}

.msg-meta .page-ref.page-ref-btn:hover {
  border-color: var(--accent-cyan-glow);
  background: hsla(190, 90%, 50%, 0.28);
  transform: translateY(-1px);
}

.msg-action-btn {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: var(--text-dark);
  border: none;
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.5rem;
  box-shadow: 0 0 10px rgba(190, 90, 50, 0.3);
  transition: var(--transition-fast);
}

.msg-action-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 0 15px rgba(190, 90, 50, 0.5);
}

.copilot-header-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge-muted {
  opacity: 0.85;
  background: hsla(215, 20%, 30%, 0.35) !important;
  border-color: var(--border-glass) !important;
  color: var(--text-muted) !important;
}

.badge-muted.quota-exhausted {
  background: hsla(0, 85%, 60%, 0.12) !important;
  border-color: hsla(0, 85%, 60%, 0.35) !important;
  color: hsl(0, 85%, 65%) !important;
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border-glass);
  background: var(--bg-secondary);
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chat-input-area input {
  flex: 1;
  background: hsla(224, 71%, 4%, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  color: var(--text-main);
  padding: 0.8rem 1rem;
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}

.chat-input-area input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.ask-selected-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  background: hsla(190, 90%, 50%, 0.08);
  border: 1px solid hsla(190, 90%, 50%, 0.25);
}

.ask-selected-bar[hidden] {
  display: none !important;
}

.ask-selected-label {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ask-selected-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--accent-cyan-glow);
  background: hsla(190, 90%, 50%, 0.15);
  color: var(--accent-cyan);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition-fast);
}

.ask-selected-btn:hover {
  background: var(--accent-cyan);
  color: var(--text-dark);
}

.ask-selected-btn i {
  width: 13px;
  height: 13px;
}

.ask-selected-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  font-family: var(--font-family);
}

.ask-selected-clear:hover {
  color: var(--text-main);
}

.data-table tr.row-selected td {
  background: hsla(190, 90%, 50%, 0.12) !important;
  box-shadow: inset 3px 0 0 var(--accent-cyan);
}

.send-btn {
  background: var(--bg-glass-active);
  border: 1px solid var(--border-glass);
  color: var(--accent-cyan);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--accent-cyan);
  color: var(--text-dark);
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

/* Page context modal (Copilot jump-to-page) */
.page-context-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: hsla(220, 40%, 4%, 0.65);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}

.page-context-modal[hidden] {
  display: none !important;
}

.page-context-panel {
  width: min(720px, 100%);
  max-height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
}

.page-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-glass);
  background: var(--bg-glass);
}

.page-context-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.page-context-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
}

.page-context-close:hover {
  color: var(--text-main);
  background: hsla(0, 0%, 100%, 0.06);
}

.page-context-body {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-family);
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-main);
  background: hsla(220, 40%, 6%, 0.35);
}

/* stats panel styling */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: stretch;
}

.stats-grid > .stat-card {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.stats-grid .stat-info {
  min-width: 0;
  flex: 1 1 auto;
}

.stats-grid .stat-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-grid .stat-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.confidence-filter-bar {
  width: auto;
  min-width: 180px;
}

.confidence-filter-bar .settings-select {
  padding: 0.45rem 0.8rem;
  width: 100%;
  min-width: 180px;
}

.stat-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

/* Extraction Quality card — soft score tones (not neon) */
button.stat-card.quality-score-card {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

button.stat-card.quality-score-card:hover {
  border-color: var(--border-glass-glow);
}

button.stat-card.quality-score-card:focus-visible {
  outline: 2px solid var(--accent-cyan-glow);
  outline-offset: 2px;
}

.quality-score-card.score-high {
  background: hsla(152, 42%, 42%, 0.23);
  border-color: hsla(152, 42%, 42%, 0.43);
}

.quality-score-card.score-mid {
  background: hsla(36, 58%, 48%, 0.24);
  border-color: hsla(36, 58%, 48%, 0.45);
}

.quality-score-card.score-low {
  background: hsla(0, 48%, 52%, 0.23);
  border-color: hsla(0, 48%, 52%, 0.43);
}

html[data-theme="light"] .quality-score-card.score-high {
  background: hsla(152, 38%, 42%, 0.22);
  border-color: hsla(152, 38%, 36%, 0.37);
}

html[data-theme="light"] .quality-score-card.score-mid {
  background: hsla(36, 52%, 50%, 0.23);
  border-color: hsla(36, 52%, 42%, 0.39);
}

html[data-theme="light"] .quality-score-card.score-low {
  background: hsla(0, 42%, 52%, 0.22);
  border-color: hsla(0, 42%, 46%, 0.37);
}

.quality-score-panel {
  width: min(440px, 100%);
  max-height: none;
}

.quality-score-body {
  padding: 1.15rem 1.2rem 1.35rem;
}

.quality-score-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.25rem;
  line-height: 1.2;
}

.quality-score-level {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 0.85rem;
  color: var(--text-muted);
}

.quality-score-level.score-high { color: var(--accent-green); }
.quality-score-level.score-mid { color: var(--accent-amber); }
.quality-score-level.score-low { color: hsl(0, 55%, 48%); }

.quality-score-message {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.stat-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon-wrapper i {
  width: 20px;
  height: 20px;
}

.blue-glow {
  background: hsla(190, 90%, 50%, 0.15);
  border: 1px solid var(--accent-cyan-glow);
  color: var(--accent-cyan);
}
.green-glow {
  background: hsla(145, 80%, 48%, 0.15);
  border: 1px solid var(--accent-green-glow);
  color: var(--accent-green);
}
.amber-glow {
  background: hsla(40, 95%, 55%, 0.15);
  border: 1px solid var(--accent-amber-glow);
  color: var(--accent-amber);
}
.red-glow {
  background: hsla(0, 84%, 60%, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
}
.purple-glow {
  background: hsla(270, 90%, 65%, 0.15);
  border: 1px solid var(--accent-purple-glow);
  color: var(--accent-purple);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-main);
}

/* Smaller value for text stats (e.g. "12 May 2024" on the Latest Entry card) */
.stat-value.stat-value-sm {
  font-size: 1.05rem;
  padding-top: 0.2rem;
}

/* Quality filter stays admin-only. Confidence % and Why-this-score stay visible for all users. */
body.hide-quality-ui .confidence-filter-bar {
  display: none !important;
}

/* Registry Database Grid Card */
.grid-card {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.grid-toolbar {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: hsla(220, 20%, 12%, 0.6);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-btn:hover {
  border-color: hsla(215, 20%, 35%, 1);
  color: var(--text-main);
}

.tab-btn.active {
  background: hsla(190, 90%, 50%, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: flex-end;
}

.grid-search-bar {
  position: relative;
  width: 320px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.grid-search-bar input {
  width: 100%;
  background: hsla(220, 30%, 8%, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  color: var(--text-main);
  padding: 0.6rem 1rem 0.6rem 2.25rem;
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-fast);
}

.grid-search-bar input:focus {
  border-color: var(--accent-cyan-glow);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

/* Table grid rendering styling */
.grid-container {
  flex: 1;
  overflow: auto;
  width: 100%;
  max-width: 100%;
  background: hsla(220, 40%, 6%, 0.15);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: hsla(220, 20%, 10%, 0.9);
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--border-glass);
}

.data-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid hsla(217, 30%, 16%, 0.6);
  color: var(--text-main);
  transition: var(--transition-fast);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tr:hover td {
  background: hsla(220, 20%, 18%, 0.35);
  color: var(--text-main);
}

/* Frequency tag coloring */
.freq-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}

.freq-tag.tag-hours {
  background: hsla(270, 90%, 65%, 0.15);
  color: var(--accent-purple);
  border: 1px solid var(--accent-purple-glow);
}

.freq-tag.tag-days {
  background: hsla(190, 90%, 50%, 0.15);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan-glow);
}

.freq-tag.tag-months {
  background: hsla(40, 95%, 55%, 0.15);
  color: var(--accent-amber);
  border: 1px solid var(--accent-amber-glow);
}

.freq-tag.tag-years {
  background: hsla(0, 85%, 60%, 0.12);
  color: hsl(0, 85%, 65%);
  border: 1px solid hsla(0, 85%, 60%, 0.25);
}

.freq-tag.tag-parts {
  background: hsla(145, 80%, 48%, 0.15);
  color: var(--accent-green);
  border: 1px solid var(--accent-green-glow);
}

.page-cell {
  color: var(--text-muted);
  font-weight: 500;
}

/* Edit Cell Outline */
td.editing {
  background: hsla(190, 90%, 50%, 0.1) !important;
  outline: 1.5px solid var(--accent-cyan);
  padding: 0.4rem !important;
}

td.editing input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.88rem;
  outline: none;
  padding: 0.4rem;
}

/* Row Action Buttons — keep td as table-cell (flex on td breaks row borders) */
.row-actions {
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.row-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  transition: var(--transition-fast);
}

.row-btn.btn-approve:hover {
  background: hsla(145, 80%, 48%, 0.18);
  color: var(--accent-green);
}

.row-btn.btn-reject:hover {
  background: color-mix(in srgb, var(--accent-red) 18%, transparent);
  color: var(--accent-red);
}

.row-btn.btn-delete:hover {
  background: hsla(0, 85%, 60%, 0.15);
  color: var(--accent-red);
}

.row-btn i {
  width: 14px;
  height: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}

.status-pill.status-approved {
  background: var(--accent-green-glow);
  color: var(--accent-green);
  border: 1px solid color-mix(in srgb, var(--accent-green) 40%, transparent);
}

.status-pill.status-pending {
  background: hsla(215, 90%, 55%, 0.12);
  color: var(--accent-blue);
  border: 1px solid color-mix(in srgb, var(--accent-blue) 40%, transparent);
}

.status-pill.status-rejected {
  background: color-mix(in srgb, var(--accent-red) 16%, transparent);
  color: var(--accent-red);
  border: 1px solid color-mix(in srgb, var(--accent-red) 40%, transparent);
}

.status-pill.status-draft {
  background: hsla(0, 0%, 50%, 0.12);
  color: var(--text-muted);
  border: 1px solid hsla(0, 0%, 50%, 0.3);
}

.status-cell-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  min-width: 0;
  max-width: 160px;
}

.status-comment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  max-width: 150px;
  padding: 0.12rem 0.45rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent-amber, #f59e0b) 35%, transparent);
  background: color-mix(in srgb, var(--accent-amber, #f59e0b) 12%, transparent);
  color: var(--accent-amber, #d97706);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  text-align: left;
}

.status-comment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-comment-chip i,
.status-comment-chip svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.status-history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.status-history-btn:hover,
.status-comment-chip:hover {
  filter: brightness(1.08);
}

.status-history-btn i,
.status-history-btn svg {
  width: 13px;
  height: 13px;
}

.row-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 360px;
  overflow-y: auto;
}

.row-history-item {
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle, var(--border-glass));
  background: var(--surface-soft);
}

.row-history-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.row-history-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.row-history-comment {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--text-main);
}

.row-history-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

#signoff-all-btn {
  border-color: color-mix(in srgb, var(--accent-green) 42%, var(--border-glass));
  color: var(--accent-green);
}

.doc-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  background: hsla(210, 90%, 55%, 0.08);
  border-color: hsla(210, 90%, 55%, 0.35);
  color: var(--accent-blue);
}

.doc-meta-badge:hover {
  background: hsla(210, 90%, 55%, 0.15);
}


/* Grid Empty State */
.table-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.table-empty-state h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

/* Grid Footer Component */
.grid-footer {
  position: relative;
  padding: 1rem;
  border-top: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: hsla(220, 40%, 6%, 0.15);
}

.grid-disclaimer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: max-content;
  max-width: calc(100% - 11rem);
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.3;
  color: hsla(215, 10%, 45%, 0.9);
  white-space: nowrap;
}

.grid-copyright {
  margin: 0;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  white-space: nowrap;
}

html[data-theme="light"] .grid-container,
html[data-theme="light"] .grid-footer {
  background: #ffffff;
}

/* Premium Button Styling System */
.btn {
  font-family: var(--font-family);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: var(--text-dark);
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(190, 90, 50, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(190, 90, 50, 0.45);
}

.btn-primary i {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: var(--bg-glass-active);
  border-color: var(--border-glass);
  color: var(--text-main);
}

.btn-secondary:hover {
  border-color: var(--accent-cyan-glow);
  background: hsla(190, 90%, 50%, 0.05);
  color: var(--accent-cyan);
}

.btn-secondary i {
  width: 16px;
  height: 16px;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: hsla(215, 20%, 35%, 1);
}

/* Danger Button */
.btn-danger {
  background: linear-gradient(135deg, hsl(0, 85%, 60%), hsl(340, 85%, 50%));
  color: var(--text-main);
  box-shadow: 0 4px 15px rgba(255, 60, 60, 0.25);
  border: none;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 60, 60, 0.45);
  background: linear-gradient(135deg, hsl(0, 95%, 65%), hsl(340, 95%, 55%));
}

.btn-danger i {
  width: 16px;
  height: 16px;
}

/* AI Engine Settings Card */
.settings-card {
  margin-top: 0rem;
  padding: 0;
}

.settings-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

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

.settings-select, .settings-input {
  background: hsla(220, 30%, 8%, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  color: var(--text-main);
  padding: 0.6rem;
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-fast);
  width: 100%;
}

.settings-select:focus, .settings-input:focus {
  border-color: var(--accent-cyan-glow);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.settings-select option {
  background: var(--bg-secondary);
  color: var(--text-main);
}

/* Loading Spin Utility */
.spin {
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

.spin-loading {
  animation: spin 1s infinite linear;
}

/* Registry Mode Tabs Selector */
.registry-mode-container {
  display: flex;
  margin-bottom: 0.85rem;
}

.registry-mode-tabs {
  display: flex;
  background: hsla(220, 30%, 8%, 0.6);
  border: 1px solid var(--border-glass);
  padding: 0.25rem;
  border-radius: 10px;
  gap: 0.2rem;
}

.mode-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-fast);
}

.mode-tab-btn:hover {
  color: var(--text-main);
  background: hsla(220, 20%, 18%, 0.2);
}

.mode-tab-btn.active {
  background: hsla(190, 90%, 50%, 0.15);
  border: 1px solid var(--accent-cyan-glow);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(190, 90, 50, 0.15);
}

.mode-tab-btn i {
  width: 14px;
  height: 14px;
}

/* Theme toggle (header icon-only) */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  border-radius: 30px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition-fast);
}

.theme-toggle-btn:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan-glow);
  background: hsla(190, 90%, 50%, 0.08);
}

.theme-toggle-btn i {
  width: 15px;
  height: 15px;
}

.theme-toggle-btn .theme-icon-sun,
.theme-toggle-btn .theme-icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-toggle-btn .theme-icon-sun,
html:not([data-theme]) .theme-toggle-btn .theme-icon-sun {
  display: inline-block;
}

html[data-theme="light"] .theme-toggle-btn .theme-icon-moon {
  display: inline-block;
}

/* Light-mode surface / control overrides for hardcoded dark fills */
html[data-theme="light"] .glass-card,
html[data-theme="light"] .app-header,
html[data-theme="light"] .settings-card,
html[data-theme="light"] .upload-card {
  background: var(--bg-glass);
  box-shadow: var(--shadow-elevated);
}

html[data-theme="light"] .progress-overlay.active {
  background: hsl(210, 14%, 93%);
  border-color: hsla(214, 18%, 70%, 0.85);
  box-shadow: 0 12px 36px rgba(30, 50, 80, 0.14);
}

html[data-theme="light"] .progress-drag-handle {
  background: hsla(210, 12%, 86%, 0.9);
  border-bottom-color: hsla(214, 16%, 78%, 0.95);
}

html[data-theme="light"] .upload-zone,
html[data-theme="light"] .drop-zone,
html[data-theme="light"] #drop-zone.upload-card {
  background: var(--bg-glass);
}

html[data-theme="light"] .settings-select,
html[data-theme="light"] .settings-input,
html[data-theme="light"] input[type="number"].settings-input,
html[data-theme="light"] #grid-search,
html[data-theme="light"] .chat-input,
html[data-theme="light"] #chat-input {
  background: var(--surface-soft-2);
  color: var(--text-main);
  border-color: var(--border-glass);
}

html[data-theme="light"] .data-table thead th {
  background: var(--surface-header);
  color: var(--text-main);
  border-bottom-color: var(--border-glass);
}

html[data-theme="light"] .data-table tbody tr {
  background: var(--surface-row);
  border-bottom-color: var(--border-glass);
}

html[data-theme="light"] .data-table tbody tr:hover {
  background: hsla(192, 60%, 45%, 0.08);
}

html[data-theme="light"] .tab-btn,
html[data-theme="light"] .mode-tab-btn {
  background: transparent;
}

html[data-theme="light"] .registry-mode-tabs,
html[data-theme="light"] .filter-tabs,
html[data-theme="light"] .tabs-container {
  background: var(--surface-soft-2);
}

html[data-theme="light"] .mode-tab-btn:hover,
html[data-theme="light"] .tab-btn:hover {
  background: hsla(210, 20%, 90%, 0.9);
  color: var(--text-main);
}

html[data-theme="light"] .mode-tab-btn.active,
html[data-theme="light"] .tab-btn.active {
  background: hsla(192, 78%, 32%, 0.1);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan-glow);
  box-shadow: none;
}

html[data-theme="light"] .stat-card {
  background: var(--bg-glass);
  border-color: var(--border-glass);
  box-shadow: var(--shadow-elevated);
}

html[data-theme="light"] .msg-content {
  background: var(--surface-soft-2);
  color: var(--text-main);
  border-color: var(--border-glass);
}

html[data-theme="light"] .btn-secondary,
html[data-theme="light"] .row-btn {
  background: var(--surface-soft);
  color: var(--text-muted);
  border-color: var(--border-glass);
}

html[data-theme="light"] .btn-primary {
  color: #fff;
}

html[data-theme="light"] .logo-icon {
  box-shadow: none;
}

html[data-theme="light"] .table-empty-state,
html[data-theme="light"] .empty-icon {
  color: var(--text-muted);
}

html[data-theme="light"] .page-range-row,
html[data-theme="light"] .page-range-hint {
  color: var(--text-muted);
}

html[data-theme="light"] #active-doc-name {
  background: hsla(0, 72%, 46%, 0.08) !important;
}

html[data-theme="light"] .theme-toggle-btn:hover {
  background: hsla(192, 78%, 32%, 0.08);
}

html[data-theme="light"] .chat-messages,
html[data-theme="light"] .table-scroll-container,
html[data-theme="light"] .registry-toolbar,
html[data-theme="light"] .grid-toolbar,
html[data-theme="light"] .right-panel .glass-card {
  background: var(--bg-glass);
}

html[data-theme="light"] .chat-input-area {
  background: var(--surface-soft-2);
  border-color: var(--border-glass);
}

html[data-theme="light"] td.editable.editing,
html[data-theme="light"] .data-table td.editing {
  background: hsla(192, 70%, 40%, 0.08) !important;
}

html[data-theme="light"] .freq-tag,
html[data-theme="light"] .tag-parts {
  background: hsla(192, 78%, 32%, 0.1);
}

html[data-theme="light"] .btn-danger {
  color: #fff;
}

.confidence-cell {
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}

.score-reasons-cell {
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-muted);
  max-width: 240px;
  white-space: normal;
  vertical-align: middle;
}

.score-reasons-ok {
  color: hsl(145, 45%, 38%);
  font-weight: 600;
}

.score-reasons-btn {
  text-align: left;
  max-width: 100%;
  white-space: normal;
  text-decoration: none;
  font-weight: 500;
  line-height: 1.35;
  padding: 0.2rem 0.35rem;
}

.data-table tr.row-low-confidence .score-reasons-cell {
  color: var(--accent-amber);
}

.confidence-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0.15rem 0.45rem;
  border-radius: 8px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.confidence-btn:hover,
.confidence-btn:focus-visible {
  border-color: var(--border-glass);
  background: hsla(215, 40%, 50%, 0.12);
  outline: none;
}

.data-table tr.row-low-confidence td {
  background: hsla(36, 85%, 45%, 0.1);
}

.data-table tr.row-low-confidence .confidence-cell {
  color: var(--accent-amber);
}

.row-confidence-panel {
  max-width: 520px;
  max-height: min(88vh, 720px);
  overflow-y: auto;
}

.row-confidence-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.row-confidence-detail {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.rc-block {
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: var(--bg-glass);
}

.rc-block-title {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.rc-block-text {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.rc-list {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--text-main);
}

.rc-compare-label {
  margin: 0.65rem 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.rc-compare-box {
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: hsla(215, 20%, 50%, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 7.5rem;
  overflow-y: auto;
}

.rc-pdf-snip mark {
  background: hsla(48, 95%, 55%, 0.45);
  color: inherit;
  padding: 0 0.1em;
  border-radius: 3px;
}

.rc-missing-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.rc-missing-word {
  display: inline-flex;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: hsla(0, 75%, 52%, 0.14);
  color: hsl(0, 70%, 42%);
  border: 1px solid hsla(0, 75%, 52%, 0.3);
}

.row-confidence-body {
  padding: 0.25rem 0 0.5rem;
}

.row-confidence-score {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--text-main);
}

.row-confidence-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.row-confidence-metrics .row-confidence-metric:nth-child(3) {
  grid-column: 1 / -1;
}

.row-confidence-metric {
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: var(--bg-glass);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.row-confidence-metric span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.row-confidence-metric strong {
  font-size: 1rem;
  color: var(--text-main);
}

.row-confidence-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.row-confidence-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.reason-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.reason-tag.reason-ok {
  background: hsla(145, 55%, 40%, 0.18);
  color: hsl(145, 55%, 42%);
  border-color: hsla(145, 55%, 40%, 0.35);
}

.reason-tag.reason-warn {
  background: hsla(36, 90%, 48%, 0.16);
  color: hsl(32, 85%, 40%);
  border-color: hsla(36, 90%, 48%, 0.4);
}

.reason-tag.reason-bad {
  background: hsla(0, 75%, 52%, 0.14);
  color: hsl(0, 70%, 45%);
  border-color: hsla(0, 75%, 52%, 0.35);
}

.row-confidence-note {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.row-confidence-actions {
  margin-top: 0.85rem;
}

.row-confidence-actions .btn {
  width: 100%;
}

.data-table tr.row-confidence-flash td {
  animation: rowConfidenceFlash 1.6s ease;
}

@keyframes rowConfidenceFlash {
  0%, 100% { background: transparent; }
  25%, 55% { background: hsla(192, 70%, 45%, 0.22); }
}

html[data-theme="light"] .data-table tr.row-low-confidence td {
  background: hsla(36, 85%, 42%, 0.12);
}

html[data-theme="light"] .data-table tr:hover.row-low-confidence td {
  background: hsla(36, 85%, 42%, 0.18);
}

html[data-theme="light"] .data-table tr:hover td {
  background: hsla(192, 60%, 45%, 0.08);
}

html[data-theme="light"] .data-table td {
  border-bottom-color: var(--border-glass);
}

html[data-theme="light"] .profile-dropdown {
  background: var(--bg-secondary);
  box-shadow: 0 12px 32px rgba(30, 50, 80, 0.12);
}

html[data-theme="light"] .auth-modal {
  background: hsla(210, 28%, 96%, 0.72);
}

html[data-theme="light"] .admin-page-card.glass-card {
  background: var(--bg-glass);
  box-shadow: var(--shadow-elevated);
}

html[data-theme="light"] .admin-page-body,
html[data-theme="light"] .admin-page-body .app-container {
  background-color: transparent;
  color: var(--text-main);
}

.admin-page-body {
  overflow: hidden;
  height: 100vh;
}

.admin-page-body .app-container.admin-page {
  /* Fill the viewport so zoom-out doesn't leave a dead band under the UI */
  max-width: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 1.25rem 1.5rem 0.65rem;
}

.admin-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Active admin panel consumes remaining height; footer stays under content */
.admin-page > .admin-view:not([hidden]),
.admin-page > .stats-grid.admin-view:not([hidden]) {
  flex-shrink: 0;
}

.admin-page > .admin-ops-section.admin-view:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: hsla(215, 20%, 40%, 0.55) transparent;
}

.admin-page > .admin-page-card.admin-view:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-page.app-container > .app-page-footer {
  margin-top: auto;
  flex-shrink: 0;
}

.admin-page > .app-header {
  margin-bottom: 0;
}

.admin-page .header-status {
  gap: 0.5rem;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.95rem;
  border-radius: 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-elevated);
  box-sizing: border-box;
}

.admin-nav-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.admin-nav-refresh {
  box-sizing: border-box;
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  padding: 0;
  margin-left: auto;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--surface-soft);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  box-shadow: none;
}

.admin-nav-refresh:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan-glow);
  background: hsla(190, 90%, 50%, 0.08);
}

.admin-nav-refresh i,
.admin-nav-refresh svg {
  width: 15px;
  height: 15px;
  display: block;
}

.admin-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  box-sizing: border-box;
  height: 2.6rem;
  min-height: 2.6rem;
  padding: 0 1.05rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-fast);
  flex: 0 0 auto;
  margin: 0;
}

.admin-nav-btn i,
.admin-nav-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

.admin-nav-btn span {
  line-height: 1;
  display: block;
}

.admin-nav-btn:hover {
  color: var(--text-main);
  background: hsla(210, 20%, 50%, 0.08);
}

.admin-nav-btn.active {
  color: var(--accent-cyan);
  background: hsla(192, 70%, 42%, 0.1);
  border-color: hsla(192, 70%, 42%, 0.28);
}

.admin-view[hidden] {
  display: none !important;
}

.admin-page-card {
  padding: 1.35rem 1.4rem 1.5rem;
  overflow: visible;
}

.admin-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.admin-section-head > .history-toolbar,
.admin-section-head > .btn.history-toolbar-control {
  margin-left: auto;
}

.admin-section-head .btn.history-toolbar-control {
  justify-content: center;
  gap: 0.4rem;
  width: auto;
  min-width: 0;
}

.admin-section-head .btn.history-toolbar-control i {
  width: 15px;
  height: 15px;
}

.admin-section-head h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}

.admin-section-sub {
  margin: 0.3rem 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.admin-page-intro {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.admin-page-intro h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.admin-page .admin-table-wrap {
  padding: 0.75rem 0 0;
}

.admin-page .admin-create-grid {
  padding: 0;
}

.admin-page-card[data-admin-panel="users"] .admin-section-head {
  flex-shrink: 0;
}

.admin-users-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  margin-bottom: 0.85rem;
}

@media (max-width: 1100px) {
  .admin-users-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(12rem, 1fr);
    overflow: auto;
  }
}

.admin-subcard {
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  background: var(--bg-glass);
  padding: 1rem 1.1rem 1.15rem;
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Create user: content-sized, scrolls when zoomed or viewport is short */
.admin-users-layout > .admin-subcard:not(.admin-directory-card) {
  align-self: start;
  width: 100%;
  height: auto;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: hsla(215, 20%, 40%, 0.55) transparent;
}

.admin-users-layout > .admin-subcard:not(.admin-directory-card)::-webkit-scrollbar {
  width: 8px;
}

.admin-users-layout > .admin-subcard:not(.admin-directory-card)::-webkit-scrollbar-track {
  background: transparent;
}

.admin-users-layout > .admin-subcard:not(.admin-directory-card)::-webkit-scrollbar-thumb {
  background: hsla(215, 20%, 40%, 0.45);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.admin-users-layout > .admin-subcard:not(.admin-directory-card)::-webkit-scrollbar-thumb:hover {
  background: hsla(215, 20%, 40%, 0.7);
  background-clip: padding-box;
}

html[data-theme="light"] .admin-users-layout > .admin-subcard:not(.admin-directory-card) {
  scrollbar-color: hsla(215, 14%, 55%, 0.45) transparent;
}

/* Directory fills the panel height and scrolls rows inside */
.admin-directory-card {
  align-self: stretch;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Clip scroll paint — no top padding (padding caused ghost rows above sticky header) */
.admin-directory-scroll.admin-table-wrap,
.admin-directory-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 !important;
  margin: 0;
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
  isolation: isolate;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-cyan, #06b6d4) rgba(255, 255, 255, 0.08);
}

.admin-directory-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.admin-directory-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.admin-directory-scroll::-webkit-scrollbar-thumb {
  background: var(--accent-cyan, #06b6d4);
  border-radius: 6px;
}

.admin-directory-scroll::-webkit-scrollbar-thumb:hover {
  background: #22d3ee;
}

html[data-theme="light"] .admin-directory-scroll {
  scrollbar-color: hsl(215, 20%, 60%) rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .admin-directory-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
}

html[data-theme="light"] .admin-directory-scroll::-webkit-scrollbar-thumb {
  background: hsl(215, 20%, 60%);
}

/* separate + spacing 0 fixes sticky bleed with border-collapse:collapse */
.admin-directory-scroll .admin-users-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.admin-directory-scroll .admin-users-table thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  /* Fully opaque so scrolled rows can't show through */
  background: hsl(223, 47%, 9%);
  background-clip: padding-box;
  box-shadow: 0 1px 0 var(--border-glass);
}

html[data-theme="light"] .admin-directory-scroll .admin-users-table thead th {
  background: hsl(210, 14%, 88%);
  color: var(--text-main);
}

.admin-directory-scroll .admin-users-table tbody td {
  position: relative;
  z-index: 0;
  background-clip: padding-box;
}

.admin-directory-scroll .admin-users-table tbody tr {
  position: relative;
  z-index: 0;
}

/* Keep row controls under the sticky header while scrolling */
.admin-directory-scroll .settings-select,
.admin-directory-scroll .settings-input,
.admin-directory-scroll .admin-assigned-models,
.admin-directory-scroll .btn {
  position: relative;
  z-index: 0;
}

.admin-subcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 30px;
  margin-bottom: 0.85rem;
  padding: 0 0 0.65rem;
  border-bottom: 1px solid var(--border-glass);
  box-sizing: content-box;
  flex-shrink: 0;
  overflow: visible;
}

.admin-subcard-head h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
}

.admin-subcard-head .btn.history-toolbar-control,
.admin-subcard-head .btn.toolbar-icon-btn {
  justify-content: center;
  align-items: center;
  gap: 0;
  width: 30px;
  min-width: 30px;
  max-width: 30px;
  height: 30px;
  min-height: 30px;
  max-height: 30px;
  flex: 0 0 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--surface-soft);
  color: var(--text-muted);
  box-shadow: none;
}

.admin-subcard-head .btn.history-toolbar-control:hover,
.admin-subcard-head .btn.toolbar-icon-btn:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan-glow);
  background: hsla(190, 90%, 50%, 0.08);
}

.admin-subcard-head .btn.history-toolbar-control i,
.admin-subcard-head .btn.toolbar-icon-btn i,
.admin-subcard-head .btn.history-toolbar-control svg,
.admin-subcard-head .btn.toolbar-icon-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.admin-create-actions {
  display: flex;
  align-items: flex-end;
}

.admin-create-actions .btn {
  width: 100%;
  justify-content: center;
  height: 38px;
}

.admin-models-cell .settings-select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.admin-page .header-status .btn i {
  width: 16px;
  height: 16px;
}

/* Admin monitoring — uses main-app stat-card row */
.admin-monitor-stats,
.admin-users-stats,
.admin-logs-stats {
  width: 100%;
  margin: 0;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
}

.admin-monitor-stats .stat-meta {
  /* Kept for JS updates / hover title; visual matches main app cards */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.admin-monitor-stats .stat-card[data-tone="ok"] {
  border-color: hsla(152, 38%, 42%, 0.35);
}

.admin-monitor-stats .stat-card[data-tone="warn"] {
  border-color: hsla(36, 52%, 48%, 0.4);
}

.admin-monitor-stats .stat-card[data-tone="bad"] {
  border-color: hsla(0, 42%, 52%, 0.4);
}

.admin-monitor-card {
  background: linear-gradient(
    135deg,
    hsla(192, 50%, 45%, 0.06),
    var(--bg-glass) 42%
  );
}

html[data-theme="light"] .admin-monitor-card {
  background: linear-gradient(
    135deg,
    hsla(192, 45%, 42%, 0.07),
    var(--bg-glass) 45%
  );
}

.admin-monitor-note {
  margin: 0.9rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  font-size: 0.84rem;
  line-height: 1.4;
  color: hsl(0, 45%, 42%);
  background: hsla(0, 45%, 52%, 0.08);
  border: 1px solid hsla(0, 45%, 52%, 0.2);
}

html[data-theme="light"] .admin-monitor-note {
  color: hsl(0, 48%, 38%);
}

.admin-ops-section {
  margin-top: 0.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  width: 100%;
}

.admin-ops-section.admin-view[hidden] {
  display: none !important;
}

.admin-ops-heading {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.admin-ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 1100px) {
  .admin-ops-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .admin-ops-grid {
    grid-template-columns: 1fr;
  }
}

.admin-ops-card {
  margin: 0;
  min-width: 0;
}

.admin-ops-card .stat-value-sm {
  font-size: 1.05rem;
  word-break: break-word;
}

.admin-ops-card .stat-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-ops-card[data-tone="ok"] {
  border-color: hsla(152, 38%, 42%, 0.35);
}

.admin-ops-card[data-tone="warn"] {
  border-color: hsla(36, 52%, 48%, 0.4);
}

.admin-ops-card[data-tone="bad"] {
  border-color: hsla(0, 42%, 52%, 0.4);
}

/* Auth / Admin */
.auth-header-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  text-decoration: none;
}

a.btn.auth-back-btn,
.btn.toolbar-icon-btn,
.history-toolbar .btn.toolbar-icon-btn,
.admin-section-head .btn.toolbar-icon-btn {
  box-sizing: border-box;
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  padding: 0;
  justify-content: center;
  align-items: center;
  flex: 0 0 38px;
  text-decoration: none;
}

.auth-header-btn[hidden],
#auth-admin-btn[hidden],
#auth-logout-btn[hidden],
#auth-login-btn[hidden],
#profile-menu[hidden] {
  display: none !important;
}

.profile-menu {
  position: relative;
  z-index: 110;
}

.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.55rem 0.28rem 0.28rem;
  border-radius: 999px;
  border: 1px solid var(--border-glass);
  background: var(--surface-soft);
  color: var(--text-main);
  cursor: pointer;
  font-family: var(--font-family);
  transition: var(--transition-fast);
}

.profile-trigger:hover,
.profile-trigger[aria-expanded="true"] {
  border-color: var(--accent-cyan-glow);
  background: hsla(190, 90%, 50%, 0.08);
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: var(--text-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.profile-name {
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-caret {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.profile-dropdown {
  position: fixed;
  top: 72px;
  right: 24px;
  min-width: 240px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 0.4rem;
  z-index: 3200;
}

.profile-dropdown[hidden] {
  display: none !important;
}

.profile-dropdown-head {
  padding: 0.65rem 0.75rem 0.55rem;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 0.3rem;
}

.profile-dropdown-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
}

.profile-dropdown-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  word-break: break-all;
}

.profile-dropdown-meta {
  font-size: 0.72rem;
  color: var(--accent-cyan);
  margin-top: 0.35rem;
}

.profile-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.86rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.profile-dropdown-item:hover {
  background: hsla(190, 90%, 50%, 0.1);
}

.profile-dropdown-item i {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.profile-dropdown-danger:hover {
  background: hsla(0, 85%, 60%, 0.12);
  color: hsl(0, 85%, 65%);
}

.profile-dropdown-danger:hover i {
  color: hsl(0, 85%, 65%);
}

.auth-user-chip {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: hsla(220, 40%, 4%, 0.7);
  backdrop-filter: blur(6px);
}

.auth-modal[hidden] {
  display: none !important;
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
}

.auth-panel-wide {
  width: min(980px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
}

.auth-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-glass);
}

.auth-panel-header h3 {
  font-size: 1.05rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-error {
  color: hsl(0, 85%, 65%);
  font-size: 0.82rem;
  min-height: 1.1em;
}

.admin-muted {
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0;
}

.admin-cell-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
}

.admin-cell-primary {
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

.admin-cell-sub {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  margin: 0;
  padding: 0;
}

.history-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.history-toolbar-control {
  box-sizing: border-box;
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  margin: 0;
  padding: 0 0.75rem;
  border-radius: 8px;
  font-size: 0.84rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}

.history-toolbar select.history-toolbar-control {
  width: max-content;
  min-width: max-content;
  padding-right: 1.6rem;
  field-sizing: content;
}

.history-toolbar input.history-toolbar-control {
  width: auto;
  min-width: 0;
  max-width: 18rem;
  field-sizing: content;
}

.history-toolbar input.history-toolbar-control[type="search"] {
  /* Fit "Filter name" fully; grow a bit while typing */
  width: 12.5rem;
  min-width: 12.5rem;
  max-width: 18rem;
}

.history-toolbar input.history-toolbar-control[type="date"] {
  width: auto;
  min-width: max-content;
  max-width: none;
}

.history-toolbar .btn.history-toolbar-control:not(.toolbar-icon-btn) {
  justify-content: center;
  gap: 0.4rem;
  width: auto;
  min-width: 0;
  padding: 0 0.85rem;
}

.history-toolbar .btn.history-toolbar-control i {
  width: 15px;
  height: 15px;
}

.history-stats-grid {
  margin: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  width: 100%;
}

@media (max-width: 1100px) {
  .history-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .history-stats-grid {
    grid-template-columns: 1fr;
  }
}

.history-page .stat-card {
  min-width: 0;
}

.app-page-footer {
  margin-top: auto;
  padding: 0.85rem 1.25rem 1.1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  flex-shrink: 0;
}

.profile-dropdown-item {
  text-decoration: none;
}

.admin-assigned-models {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.45;
  word-break: break-word;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.35rem;
  align-items: center;
}

.admin-assigned-models::before {
  content: "Assigned:";
  color: var(--text-muted);
  margin-right: 0.1rem;
}

.admin-assigned-models:empty::before {
  content: "Assigned: —";
}

.admin-assigned-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: hsla(210, 40%, 94%, 0.95);
  color: var(--text-secondary, var(--text-main));
  font-size: 0.72rem;
  line-height: 1.3;
}

html[data-theme="dark"] .admin-assigned-chip {
  background: hsla(210, 20%, 22%, 0.9);
}

.admin-assigned-remove {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.1rem;
}

.admin-assigned-remove:hover {
  color: var(--text-main);
}

.admin-create-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  padding: 0;
  flex: 0 0 auto;
}

.admin-create-grid #admin-create-error,
.admin-create-grid .admin-create-actions,
.admin-create-grid .admin-field-models {
  grid-column: 1 / -1;
}

.admin-create-grid #admin-create-error:empty {
  display: none;
  margin: 0;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.admin-field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.admin-field-models .settings-hint {
  margin: 0 0 0.35rem;
}

.admin-allowed-box {
  --admin-check-row: 1.7rem;
  --admin-check-gap: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: var(--admin-check-gap);
  padding: 0.4rem;
  border-radius: 10px;
  background: hsla(220, 30%, 8%, 0.7);
  border: 1px solid var(--border-glass);
  box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.03);
  /* Exactly 4 rows visible; rest scrolls */
  max-height: calc((var(--admin-check-row) * 4) + (var(--admin-check-gap) * 3) + 0.8rem);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: hsla(215, 20%, 40%, 0.55) transparent;
}

.admin-allowed-box::-webkit-scrollbar {
  width: 8px;
}

.admin-allowed-box::-webkit-scrollbar-track {
  background: transparent;
}

.admin-allowed-box::-webkit-scrollbar-thumb {
  background: hsla(215, 20%, 40%, 0.45);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.admin-allowed-box::-webkit-scrollbar-thumb:hover {
  background: hsla(190, 60%, 45%, 0.55);
  background-clip: padding-box;
}

html[data-theme="light"] .admin-allowed-box {
  background: var(--surface-soft);
  border-color: var(--border-glass);
  box-shadow: none;
  scrollbar-color: hsla(215, 14%, 55%, 0.45) transparent;
}

.admin-check {
  font-size: 0.8rem;
  color: var(--text-main);
  display: flex;
  gap: 0.55rem;
  align-items: center;
  cursor: pointer;
  min-height: var(--admin-check-row);
  flex: 0 0 auto;
  padding: 0.2rem 0.45rem;
  border-radius: 7px;
  transition: background 0.15s ease, color 0.15s ease;
}

.admin-check:hover {
  background: hsla(190, 90%, 50%, 0.08);
  color: var(--text-main);
}

.admin-check:has(input:checked) {
  background: hsla(190, 70%, 42%, 0.12);
  color: var(--accent-cyan);
}

.admin-check span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-check input {
  margin: 0;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.admin-models-cell {
  width: 220px;
  min-width: 200px;
  max-width: 220px;
  box-sizing: border-box;
}

.admin-models-cell > .admin-cell-stack {
  width: 100%;
  max-width: 220px;
}

.admin-models-cell .admin-model-select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.admin-allocate-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  width: 100%;
  max-width: 100%;
}

.admin-allocate-label .settings-select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.settings-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0;
  line-height: 1.35;
}

.admin-table-wrap {
  padding: 0.75rem 1rem 1.25rem;
}

.admin-table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-logs-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-page-card[data-admin-panel="logs"] .admin-section-head {
  flex-shrink: 0;
}

/* Extraction logs table fills panel and scrolls rows inside */
.admin-logs-scroll.admin-table-wrap,
.admin-logs-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 !important;
  margin: 0;
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
  isolation: isolate;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: hsla(215, 20%, 40%, 0.55) transparent;
}

.admin-logs-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.admin-logs-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.admin-logs-scroll::-webkit-scrollbar-thumb {
  background: hsla(215, 20%, 40%, 0.45);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.admin-logs-scroll::-webkit-scrollbar-thumb:hover {
  background: hsla(215, 20%, 40%, 0.7);
  background-clip: padding-box;
}

html[data-theme="light"] .admin-logs-scroll {
  scrollbar-color: hsla(215, 18%, 55%, 0.65) transparent;
}

.admin-logs-scroll .admin-logs-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.admin-logs-scroll .admin-logs-table thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  background: hsl(223, 47%, 9%);
  background-clip: padding-box;
  box-shadow: 0 1px 0 var(--border-glass);
}

html[data-theme="light"] .admin-logs-scroll .admin-logs-table thead th {
  background: hsl(210, 14%, 92%);
  color: var(--text-main);
}

.history-table-scroll {
  max-height: min(520px, calc(100vh - 270px));
  min-height: 280px;
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-cyan, #06b6d4) rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
}

.history-table-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.history-table-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.history-table-scroll::-webkit-scrollbar-thumb {
  background: var(--accent-cyan, #06b6d4);
  border-radius: 6px;
}

.history-table-scroll::-webkit-scrollbar-thumb:hover {
  background: #22d3ee;
}

.history-table-scroll .admin-logs-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: hsl(223, 47%, 9%);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--border-glass);
}

html[data-theme="light"] .history-table-scroll {
  background: hsl(0, 0%, 100%);
  scrollbar-color: hsl(215, 20%, 60%) rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .history-table-scroll .admin-logs-table thead th {
  background: hsl(210, 14%, 94%);
  color: var(--text-main);
}

.admin-logs-table td,
.admin-logs-table th {
  font-size: 0.82rem;
  vertical-align: middle;
}

.history-open-btn {
  height: 30px;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* My Extracts / admin extract-log document status badges — high contrast in both themes */
.history-status-badge {
  display: inline-block !important;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-top: 0.3rem;
  line-height: 1.25;
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid transparent;
}

.history-status-badge.is-approved {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
}

.history-status-badge.is-pending {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

.history-status-badge.is-rejected {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.history-status-badge.is-superseded {
  background: rgba(148, 163, 184, 0.16);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.35);
}

html[data-theme="light"] .history-status-badge.is-approved {
  background: #dcfce7 !important;
  color: #166534 !important;
  border-color: #86efac !important;
}

html[data-theme="light"] .history-status-badge.is-pending {
  background: #ffedd5 !important;
  color: #9a3412 !important;
  border-color: #fdba74 !important;
}

html[data-theme="light"] .history-status-badge.is-rejected {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #fca5a5 !important;
}

html[data-theme="light"] .history-status-badge.is-superseded {
  background: #f1f5f9 !important;
  color: #475569 !important;
  border-color: #cbd5e1 !important;
}

.admin-log-row {
  cursor: pointer;
}

.admin-log-row:hover td {
  background: hsla(190, 40%, 50%, 0.08);
}

.admin-logs-detail {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.85rem;
  border-top: 1px solid var(--border, hsla(0, 0%, 50%, 0.25));
  line-height: 1.45;
}

.admin-users-table td,
.admin-users-table th {
  font-size: 0.82rem;
  vertical-align: middle;
}

.admin-limit-input {
  width: 72px;
  padding: 0.35rem 0.45rem;
}

.admin-pill {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: hsla(190, 90%, 50%, 0.12);
  color: var(--accent-cyan);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
}

.admin-pill.admin-pill-ok {
  background: var(--accent-green-glow);
  border-color: color-mix(in srgb, var(--accent-green) 45%, transparent);
  color: var(--accent-green);
}

.admin-pill.admin-pill-bad {
  background: color-mix(in srgb, var(--accent-red) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent-red) 45%, transparent);
  color: var(--accent-red);
}

.admin-actions-cell {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.admin-users-table td.admin-actions {
  width: 1%;
  min-width: 10.5rem;
  padding-right: 0.85rem;
  white-space: nowrap;
  vertical-align: top;
}

.admin-actions-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  /* Sit level with Select model (below Allocate Model label + gap) */
  margin-top: calc(0.72rem * 1.35 + 0.25rem);
}

.admin-actions-row .admin-save-btn,
.admin-actions-row .admin-toggle-btn {
  box-sizing: border-box;
  height: 2.3rem;
  min-height: 2.3rem;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 1rem;
  padding-right: 1rem;
  font-size: 0.85rem;
  line-height: 1;
}

@media (max-width: 800px) {
  .admin-create-grid {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------
 * Sign-in landing page (full-screen, replaces old login modal)
 * ------------------------------------------------------------- */
.auth-landing {
  position: fixed;
  inset: 0;
  z-index: 2100;
  overflow: auto;
  background:
    radial-gradient(900px 500px at 12% -8%, var(--accent-cyan-glow), transparent 60%),
    radial-gradient(800px 460px at 96% 108%, var(--accent-purple-glow), transparent 62%),
    var(--bg-primary);
}

.auth-landing[hidden] {
  display: none !important;
}

body.workspace-locked .app-container {
  visibility: hidden !important;
  pointer-events: none !important;
}

body.workspace-locked .auth-landing-close {
  display: none !important;
}

.access-denied-card {
  text-align: center;
}

.access-denied-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.access-denied-icon svg {
  width: 28px;
  height: 28px;
}

.access-denied-card .auth-landing-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.auth-landing-close {
  position: absolute;
  top: 1.1rem;
  right: 1.35rem;
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-fast);
}

.auth-landing-close:hover {
  color: var(--text-main);
  border-color: var(--border-glass-glow);
}

.auth-landing-inner {
  min-height: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 3.5rem 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 3.5rem;
  align-items: center;
}

/* Brand / value side */
.auth-landing-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--accent-cyan);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 1.4rem;
}

.auth-landing-kicker svg {
  width: 14px;
  height: 14px;
}

.auth-landing-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.1rem;
  width: fit-content;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.auth-landing-logo:hover {
  opacity: 0.82;
}

.auth-landing-logo img {
  width: 56px;
  height: auto;
}

.auth-landing-logo h1 {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.auth-landing-logo p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.auth-landing-tagline {
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 480px;
  margin-bottom: 1.8rem;
}

.auth-landing-points {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-landing-points li {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.auth-landing-point-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--accent-cyan);
}

.auth-landing-point-icon svg {
  width: 18px;
  height: 18px;
}

.auth-landing-points strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
}

.auth-landing-points li > div > span {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* Sign-in card */
.auth-landing-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  box-shadow: var(--shadow-elevated);
  padding: 2rem 1.8rem 1.6rem;
  backdrop-filter: blur(14px);
}

.auth-landing-card h3 {
  font-size: 1.35rem;
  font-weight: 700;
}

.auth-landing-card-sub {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0.25rem 0 1.2rem;
}

.auth-landing-form {
  padding: 0;
}

.auth-landing-submit {
  width: 100%;
  justify-content: center;
  height: 42px;
  border-radius: 10px;
  font-weight: 600;
}

.sso-btn {
  width: 100%;
  height: 42px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-glass-glow, rgba(255, 255, 255, 0.2));
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sso-btn:hover {
  background: var(--bg-surface-active, rgba(255, 255, 255, 0.1));
  border-color: var(--accent-color, #3b82f6);
}

.ms-logo {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

#email-login-block[hidden] {
  display: none !important;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.6rem 0 1rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-glass, rgba(255, 255, 255, 0.12));
}

.auth-divider span {
  padding: 0 0.6rem;
}

@media (max-width: 880px) {
  .auth-landing-inner {
    grid-template-columns: 1fr;
    gap: 2.2rem;
    padding: 3rem 1.4rem;
    max-width: 560px;
  }
}

/* =============================================================
 * Compact workspace layout (primary UI)
 * Upload in header; Settings + AI Assistant as icon drawers;
 * registry tables use full page width.
 * ============================================================= */
/* Full-width single-column main area */
.app-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Fill the viewport: panel and table card stretch to the bottom so the
   empty state never leaves dead space under the card */
.right-panel {
  width: 100%;
  flex: 1 1 auto;
}

.grid-container {
  display: flex;
  flex-direction: column;
}

.grid-container .data-table {
  flex: 0 0 auto;
}

.table-empty-state {
  flex: 1 1 auto;
}

/* Consistent toolbar: quality/search/export always on their own second row,
   in the same spot on all three registry tabs (with or without filter tabs) */
.grid-toolbar .toolbar-right {
  flex: 1 1 100%;
  justify-content: flex-start;
}

/* Symmetric page padding — tool icons live in the header now */

/* ---------------- Header upload group ---------------- */
.app-header {
  gap: 1rem;
  position: relative;
  z-index: 60;
}

/* Plain button group on the right — no dashed strip */
.header-upload {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.header-upload.dragover .header-upload-btn {
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

.header-upload .active-doc-badge {
  max-width: 260px;
  overflow: hidden;
}

.header-upload .active-doc-badge.empty {
  display: none;
}

.header-upload .active-doc-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-upload-btn {
  height: 36px;
  border-radius: 9px;
  padding: 0 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  cursor: pointer;
}

.header-upload-btn svg {
  width: 16px;
  height: 16px;
}

.header-upload-caret {
  width: 14px !important;
  height: 14px !important;
  opacity: 0.8;
}

/* Upload popup: page range + file chooser. Body-level, position:fixed (JS places it). */
.upload-popover {
  position: fixed;
  top: 72px;
  right: 24px;
  width: min(540px, calc(100vw - 24px));
  max-height: min(72vh, calc(100vh - 88px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 2400;
  padding: 1rem 1.1rem 1.1rem;
  background: var(--bg-glass-active);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass-glow);
  border-radius: 14px;
  box-shadow: var(--shadow-elevated);
  cursor: default;
  text-align: left;
}

.upload-popover[hidden] {
  display: none;
}

.intake-tabs {
  display: flex;
  gap: 0.4rem;
  background: var(--bg-surface-elevated, rgba(0, 0, 0, 0.2));
  padding: 0.25rem;
  border-radius: 10px;
  border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
  margin-bottom: 0.85rem;
}

.intake-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.intake-tab svg {
  width: 15px;
  height: 15px;
}

.intake-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.intake-tab.active {
  color: var(--accent-color, #3b82f6);
  background: var(--bg-surface-active, rgba(59, 130, 246, 0.15));
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.intake-panel[hidden],
.selected-file-info[hidden] {
  display: none !important;
}

.local-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 2px dashed var(--border-glass-glow, rgba(255, 255, 255, 0.2));
  border-radius: 12px;
  padding: 1.35rem 1.25rem;
  text-align: center;
  background: var(--bg-surface-subtle, rgba(255, 255, 255, 0.02));
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  margin-top: 0.5rem;
  box-sizing: border-box;
  overflow: visible;
  isolation: isolate;
}

.local-dropzone:hover, .local-dropzone.dragover {
  border-color: var(--accent-color, #3b82f6);
  background: rgba(59, 130, 246, 0.08);
}

.dropzone-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 0 0.15rem;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.12);
  border: none;
  box-shadow: none;
  flex-shrink: 0;
  pointer-events: none;
}

.dropzone-icon {
  display: block;
  width: 24px;
  height: 24px;
  margin: 0;
  color: var(--accent-color, #3b82f6);
  opacity: 0.95;
  stroke-width: 2;
  overflow: visible;
  flex-shrink: 0;
}

.dropzone-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  max-width: 100%;
}

.dropzone-browse {
  color: var(--accent-color, #3b82f6);
  text-decoration: underline;
  cursor: pointer;
}

.dropzone-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0;
}

.selected-file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-surface-active, rgba(59, 130, 246, 0.1));
  border: 1px solid var(--border-glass-glow, rgba(59, 130, 246, 0.3));
  border-radius: 10px;
}

.selected-file-name-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-name-wrap svg {
  width: 16px;
  height: 16px;
  color: var(--accent-color, #3b82f6);
  flex-shrink: 0;
}

.upload-popover h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.7rem;
}

.upload-popover-range {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
}

.upload-popover-range .page-range-field input {
  width: 110px;
}

.upload-popover-hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
  margin: 0.6rem 0 0.85rem;
}

.upload-popover-choose {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}

.upload-popover-choose svg {
  width: 16px;
  height: 16px;
}

.sharepoint-files-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.sharepoint-files-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sharepoint-refresh-btn {
  height: 28px;
  padding: 0 0.55rem;
  font-size: 0.72rem;
  gap: 0.35rem;
}

.sharepoint-refresh-btn svg {
  width: 13px;
  height: 13px;
}

.sharepoint-files-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  background: hsla(0, 0%, 0%, 0.16);
  padding: 0.5rem;
  box-sizing: border-box;
}

.sp-breadcrumbs-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  background: hsla(215, 30%, 12%, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  margin-bottom: 0.55rem;
}

.sp-breadcrumb-trail {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  min-width: 0;
  flex: 1;
}

.sp-crumb-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--color-teal);
  font-weight: 500;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: normal;
  word-break: break-word;
  text-align: left;
}

.sp-crumb-btn:hover {
  background: hsla(190, 80%, 40%, 0.15);
  border-color: hsla(190, 80%, 50%, 0.3);
  color: #38bdf8;
}

.sp-crumb-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.sp-crumb-sep {
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 0.75rem;
  user-select: none;
}

.sp-crumb-current {
  font-weight: 600;
  color: #38bdf8;
  padding: 0.2rem 0.5rem;
  background: hsla(190, 90%, 50%, 0.12);
  border: 1px solid hsla(190, 90%, 50%, 0.25);
  border-radius: 5px;
  word-break: break-word;
  font-size: 0.78rem;
}

.sp-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.sp-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.35rem 0.25rem 0.25rem;
  margin-top: 0.2rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid hsla(215, 20%, 30%, 0.25);
}

.sharepoint-files-empty,
.sharepoint-files-error {
  margin: 0;
  padding: 0.85rem 0.9rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
}

.sharepoint-files-error {
  color: hsl(0, 75%, 68%);
}

.sharepoint-folder-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid hsla(190, 50%, 40%, 0.25);
  border-radius: 8px;
  background: hsla(210, 40%, 14%, 0.6);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: all 0.18s ease;
  margin-bottom: 0.45rem;
  box-sizing: border-box;
}

.sharepoint-folder-card:hover {
  background: hsla(190, 80%, 45%, 0.14);
  border-color: hsla(190, 90%, 50%, 0.45);
  box-shadow: 0 2px 10px hsla(190, 90%, 50%, 0.12);
  transform: translateY(-1px);
}

.sp-folder-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: hsla(190, 80%, 40%, 0.18);
  border: 1px solid hsla(190, 80%, 50%, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #38bdf8;
}

.sp-folder-icon-box svg {
  width: 17px;
  height: 17px;
}

.sp-folder-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sp-folder-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: #e0f2fe;
  line-height: 1.3;
  word-break: break-word;
}

.sp-folder-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sp-item-count-pill {
  background: hsla(215, 30%, 22%, 0.7);
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.7rem;
}

.sp-folder-open-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 500;
  color: #38bdf8;
  background: hsla(190, 90%, 50%, 0.12);
  border: 1px solid hsla(190, 90%, 50%, 0.3);
  border-radius: 6px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.sharepoint-folder-card:hover .sp-folder-open-action {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
  font-weight: 600;
}

.sp-folder-open-action svg {
  width: 13px;
  height: 13px;
}

.sharepoint-file-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid hsla(215, 20%, 25%, 0.3);
  border-radius: 8px;
  background: hsla(215, 30%, 12%, 0.4);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  margin-bottom: 0.4rem;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.sharepoint-file-item:last-child {
  margin-bottom: 0;
}

.sharepoint-file-item:hover,
.sharepoint-file-item:focus-visible {
  background: hsla(160, 80%, 40%, 0.12);
  border-color: hsla(160, 80%, 50%, 0.4);
  box-shadow: 0 2px 8px hsla(160, 80%, 50%, 0.1);
  outline: none;
}

.sharepoint-file-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--accent-cyan);
}

.sharepoint-file-meta {
  min-width: 0;
  flex: 1;
}

.sharepoint-file-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
  color: #f1f5f9;
}

.sharepoint-file-size {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Animated Spinner for Data Fetching */
@keyframes spSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.sp-spinner-ring {
  width: 28px;
  height: 28px;
  border: 3px solid hsla(192, 78%, 45%, 0.2);
  border-top-color: var(--accent-cyan, #0ea5e9);
  border-radius: 50%;
  animation: spSpin 0.75s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  margin: 0 auto 0.6rem;
}

.sharepoint-refresh-btn.spinning svg,
.sharepoint-refresh-btn.loading svg {
  animation: spSpin 0.75s linear infinite;
}

.sp-loading-container {
  padding: 2rem 1rem;
  text-align: center;
}

.sp-loading-text {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------------- Light Mode SharePoint Intake Styling ---------------- */
html[data-theme="light"] .intake-tabs {
  background: hsl(210, 20%, 93%);
  border-color: hsl(214, 20%, 86%);
}

html[data-theme="light"] .intake-tab {
  color: hsl(215, 14%, 40%);
}

html[data-theme="light"] .intake-tab:hover {
  color: hsl(222, 32%, 16%);
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .intake-tab.active {
  color: hsl(192, 78%, 32%);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .sp-breadcrumbs-container {
  background: hsl(210, 25%, 96%);
  border-color: hsl(214, 20%, 86%);
}

html[data-theme="light"] .sp-crumb-btn {
  color: hsl(192, 78%, 32%);
}

html[data-theme="light"] .sp-crumb-btn:hover {
  background: hsla(192, 78%, 32%, 0.1);
  border-color: hsla(192, 78%, 32%, 0.25);
  color: hsl(192, 85%, 26%);
}

html[data-theme="light"] .sp-crumb-sep {
  color: hsl(215, 14%, 60%);
}

html[data-theme="light"] .sp-crumb-current {
  background: hsla(192, 78%, 32%, 0.1);
  border-color: hsla(192, 78%, 32%, 0.25);
  color: hsl(192, 85%, 26%);
}

html[data-theme="light"] .sharepoint-files-list {
  background: hsl(210, 24%, 96%);
  border-color: hsl(214, 20%, 86%);
}

html[data-theme="light"] .sp-section-heading {
  color: hsl(215, 14%, 42%);
  border-bottom-color: hsl(214, 20%, 86%);
}

html[data-theme="light"] .sharepoint-folder-card {
  background: #ffffff;
  border-color: hsl(214, 20%, 86%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .sharepoint-folder-card:hover {
  background: hsla(192, 78%, 32%, 0.04);
  border-color: hsla(192, 78%, 32%, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .sp-folder-title {
  color: hsl(222, 32%, 16%);
}

html[data-theme="light"] .sp-folder-icon-box {
  background: hsla(192, 78%, 32%, 0.1);
  border-color: hsla(192, 78%, 32%, 0.25);
  color: hsl(192, 78%, 32%);
}

html[data-theme="light"] .sp-folder-meta {
  color: hsl(215, 14%, 45%);
}

html[data-theme="light"] .sp-item-count-pill {
  background: hsl(210, 18%, 90%);
  color: hsl(215, 15%, 35%);
}

html[data-theme="light"] .sp-folder-open-action {
  background: hsla(192, 78%, 32%, 0.08);
  border-color: hsla(192, 78%, 32%, 0.25);
  color: hsl(192, 78%, 32%);
}

html[data-theme="light"] .sharepoint-folder-card:hover .sp-folder-open-action {
  background: hsl(192, 78%, 32%);
  color: #ffffff;
  border-color: hsl(192, 78%, 32%);
}

html[data-theme="light"] .sharepoint-file-item {
  background: #ffffff;
  border-color: hsl(214, 20%, 86%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .sharepoint-file-item:hover,
html[data-theme="light"] .sharepoint-file-item:focus-visible {
  background: hsla(160, 60%, 40%, 0.06);
  border-color: hsla(160, 60%, 40%, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .sharepoint-file-name {
  color: hsl(222, 32%, 16%);
}

html[data-theme="light"] .sharepoint-file-size {
  color: hsl(215, 14%, 45%);
}

html[data-theme="light"] .sharepoint-files-empty {
  color: hsl(215, 14%, 45%);
}

html[data-theme="light"] .sharepoint-refresh-btn,
html[data-theme="light"] #sharepoint-back-btn {
  background: hsl(210, 20%, 93%);
  border-color: hsl(214, 20%, 82%);
  color: hsl(222, 32%, 16%);
}

html[data-theme="light"] .sharepoint-refresh-btn:hover,
html[data-theme="light"] #sharepoint-back-btn:hover {
  background: hsl(210, 20%, 88%);
}

/* ---------------- Collapsed tool icons (in the header) ---------------- */
.rail-btn {
  position: relative;
}

.rail-btn svg {
  width: 15px;
  height: 15px;
}

.rail-btn.active {
  color: var(--accent-cyan);
  border-color: var(--border-glass-glow);
  background: hsla(190, 90%, 50%, 0.08);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.rail-dot {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 6px var(--accent-red);
}

/* ---------------- Drawers ---------------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 84;
  background: hsla(220, 40%, 8%, 0.25);
  backdrop-filter: blur(2px);
}

.drawer-backdrop[hidden] {
  display: none;
}

.tool-drawer {
  position: fixed;
  right: 1.5rem;
  top: 5.4rem;
  /* Height hugs the content; long content scrolls inside. */
  max-height: calc(100vh - 7rem);
  z-index: 86;
  width: min(400px, calc(100vw - 3rem));
  display: flex;
  flex-direction: column;
  background: var(--bg-glass-active);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
  animation: drawer-in 0.22s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* The AI Assistant keeps the full height — chat needs the room. */
.tool-drawer-chat {
  bottom: 1.5rem;
}

.tool-drawer[hidden] {
  display: none;
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.tool-drawer-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-glass);
  flex: 0 0 auto;
}

.tool-drawer-head .card-title {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tool-drawer-head h2 {
  font-size: 0.98rem;
  font-weight: 600;
}

.tool-drawer-close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tool-drawer-close:hover {
  color: var(--text-main);
  border-color: var(--border-glass-glow);
}

.tool-drawer .settings-body {
  padding: 1rem;
  overflow: auto;
}

/* Chat drawer fills its height */
.tool-drawer-chat .chat-container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.tool-drawer-chat .chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .header-upload .active-doc-badge {
    max-width: 180px;
  }
}

@media (max-width: 900px) {
  .app-header {
    flex-wrap: wrap;
  }
  .header-upload .active-doc-badge {
    max-width: 140px;
  }
  .tool-drawer {
    left: 1rem;
    right: 1rem;
    width: auto;
    top: 6rem;
    max-height: calc(100vh - 7rem);
  }
  .tool-drawer-chat {
    bottom: 1rem;
  }
}

/* Craft signature — barely-there watermark (unicode-escaped; do not strip) */
body::after {
  content: "\0041\006B\0073\0068\0061\0079\0020\0052\0079\0061\006C\0069";
  position: fixed;
  right: 0.85rem;
  bottom: 0.4rem;
  z-index: 2147483000;
  font-family: var(--font-family);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0.055;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  mix-blend-mode: soft-light;
}

html[data-theme="light"] body::after {
  opacity: 0.07;
  mix-blend-mode: multiply;
  color: hsl(215, 12%, 42%);
}

#idp-craft-sig {
  position: fixed;
  left: 0.85rem;
  bottom: 0.4rem;
  z-index: 2147483000;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--font-family);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  opacity: 0.05;
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* 24-Hour Shared View Top Header Cards */
.header-badge-card {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.25s ease-out;
  flex-shrink: 0;
  margin-right: 0.25rem;
}

.header-badge-card[hidden] {
  display: none !important;
}

.header-badge-card i,
.header-badge-card svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.header-badge-cyan {
  background: hsla(190, 90%, 50%, 0.1);
  border: 1px solid hsla(190, 90%, 50%, 0.28);
  color: var(--accent-cyan, #06b6d4);
}

.header-badge-green {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: #10b981;
}

.header-badge-amber {
  background: color-mix(in srgb, var(--accent-amber, #f59e0b) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-amber, #f59e0b) 32%, transparent);
  color: var(--accent-amber, #d97706);
}

.header-badge-muted {
  background: hsla(220, 12%, 50%, 0.1);
  border: 1px solid hsla(220, 12%, 50%, 0.24);
  color: var(--text-muted);
}

.header-role-badge {
  margin-right: 0;
}

.header-role-badge-icon {
  display: inline-flex;
  align-items: center;
}

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
}

body.is-shared-viewer .confidence-cell,
body.is-shared-viewer .score-reasons-cell,
body.is-shared-viewer .row-actions,
body.is-shared-viewer .actions-cell,
body.is-shared-viewer th.actions-col,
body.is-shared-viewer .confidence-filter-bar,
body.is-shared-viewer .header-upload,
body.is-shared-viewer #signoff-btn,
body.is-shared-viewer #signoff-all-btn,
body.is-shared-viewer #auth-admin-btn,
body.is-shared-viewer #auth-login-btn,
body.is-shared-viewer #profile-menu,
body.is-shared-viewer #header-role-badge,
body.is-shared-viewer #rail-settings-btn,
body.is-shared-viewer #rail-chat-btn,
body.is-shared-viewer #share-btn,
body.is-shared-viewer #doc-meta-badge,
body.is-shared-viewer #login-modal,
body.is-shared-viewer .auth-modal,
body.is-shared-viewer .auth-landing {
  display: none !important;
}

body[data-app-role="viewer"] #save-changes-btn,
body[data-app-role="viewer"] #signoff-btn,
body[data-app-role="viewer"] #signoff-all-btn,
body[data-app-role="viewer"] #add-row-btn,
body[data-app-role="viewer"] .row-btn.btn-delete,
body[data-app-role="viewer"] .row-btn.btn-approve,
body[data-app-role="viewer"] .row-btn.btn-reject {
  display: none !important;
}

/* Notification bell — always visible for all logged-in users */
.approvals-notif-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Legacy [hidden] override removed — no longer used */

.approvals-bell-btn {
  position: relative;
  transition: all 0.2s ease;
}

.approvals-bell-btn.has-pending {
  color: var(--accent-orange, #f59e0b);
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
  animation: bell-pulse 2.5s infinite;
}

@keyframes bell-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.notif-badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--bg-surface-elevated, #0f172a);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

.notif-badge-count[hidden] {
  display: none !important;
}

.approvals-dropdown {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 2rem);
  background: var(--bg-surface-elevated, #0f172a);
  border: 1px solid var(--border-glass-glow, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.approvals-dropdown[hidden] {
  display: none !important;
}

.approvals-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  background: hsla(220, 35%, 10%, 0.5);
}

.approvals-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}

.approvals-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.approvals-clear-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.approvals-clear-btn:hover:not(:disabled) {
  color: var(--text-main, #f8fafc);
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.12);
}

.approvals-clear-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.approvals-clear-btn[hidden] {
  display: none !important;
}

.approvals-header-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.approvals-dropdown-body {
  max-height: 380px;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.approvals-item {
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.approvals-item:hover {
  background: hsla(220, 25%, 16%, 0.8);
  border-color: rgba(6, 182, 212, 0.3);
}

.approvals-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.approvals-item-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.3;
  word-break: break-word;
}

.approvals-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.approvals-item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.approvals-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ---------------- Light Mode Approvals Dropdown ---------------- */
html[data-theme="light"] .notif-badge-count {
  border-color: #ffffff;
  box-shadow: 0 1px 4px rgba(239, 68, 68, 0.35);
}

html[data-theme="light"] .approvals-dropdown {
  background: #ffffff;
  border: 1px solid hsl(214, 20%, 86%);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .approvals-dropdown-header {
  background: hsl(210, 25%, 96%);
  border-bottom: 1px solid hsl(214, 20%, 88%);
}

html[data-theme="light"] .approvals-header-title {
  color: hsl(222, 32%, 16%);
}

html[data-theme="light"] .approvals-header-badge {
  background: hsla(38, 92%, 50%, 0.12);
  color: hsl(35, 92%, 35%);
  border-color: hsla(38, 92%, 50%, 0.28);
}

html[data-theme="light"] .approvals-clear-btn {
  border-color: hsl(214, 20%, 82%);
  color: hsl(215, 16%, 40%);
}

html[data-theme="light"] .approvals-clear-btn:hover:not(:disabled) {
  color: hsl(0, 72%, 40%);
  border-color: hsla(0, 72%, 50%, 0.4);
  background: hsla(0, 72%, 50%, 0.08);
}

html[data-theme="light"] .approvals-dropdown-body {
  background: hsl(210, 24%, 97%);
}

html[data-theme="light"] .approvals-item {
  background: #ffffff;
  border: 1px solid hsl(214, 20%, 86%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .approvals-item:hover {
  background: hsla(192, 80%, 45%, 0.04);
  border-color: hsla(192, 80%, 45%, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .approvals-item-name {
  color: hsl(222, 32%, 16%);
}

html[data-theme="light"] .approvals-item-meta {
  color: hsl(215, 14%, 45%);
}

html[data-theme="light"] .approvals-empty {
  color: hsl(215, 14%, 45%);
}

/* ==========================================================================
   Dual-Storage Audit Trail & Diff Comparison Engine Styles
   ========================================================================== */

.diff-toggle-btn.diff-active {
  background: rgba(245, 158, 11, 0.15) !important;
  border-color: #f59e0b !important;
  color: #f59e0b !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

.diff-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  line-height: 1;
  margin-left: 0.35rem;
}

/* In-Grid Table Diff Highlights */
.cell-diff-modified {
  background: rgba(245, 158, 11, 0.1) !important;
  border-left: 3px solid #f59e0b !important;
  transition: background 0.2s ease;
}

.diff-badge-original {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
  text-decoration: line-through;
  opacity: 0.85;
  margin-top: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.diff-badge-custom-row {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  vertical-align: middle;
}

/* ==========================================================================
   Dual-Storage Audit Trail & Diff Comparison Engine Styles
   ========================================================================== */

.diff-toggle-btn.diff-active {
  background: rgba(245, 158, 11, 0.15) !important;
  border-color: #f59e0b !important;
  color: #f59e0b !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

.diff-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  line-height: 1;
  margin-left: 0.35rem;
}

/* In-Grid Table Diff Highlights */
.cell-diff-modified {
  background: rgba(245, 158, 11, 0.12) !important;
  border-left: 3px solid #f59e0b !important;
  transition: background 0.2s ease;
}

html[data-theme="light"] .cell-diff-modified {
  background: rgba(245, 158, 11, 0.18) !important;
  border-left: 3px solid #d97706 !important;
}

.diff-badge-original {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
  text-decoration: line-through;
  opacity: 0.85;
  margin-top: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

html[data-theme="light"] .diff-badge-original {
  color: #64748b;
}

.diff-badge-custom-row {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  vertical-align: middle;
}

html[data-theme="light"] .diff-badge-custom-row {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

/* Diff Audit Comparison Modal */
.diff-modal-panel {
  max-width: 1040px !important;
  width: 95vw !important;
  max-height: min(88vh, 900px) !important;
  height: auto !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 12px;
  background: var(--bg-secondary, #0f172a);
  border: 1px solid var(--border-glass, rgba(255,255,255,0.1));
}

html[data-theme="light"] .diff-modal-panel {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.15) !important;
}

.diff-modal-panel .page-context-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-glass, rgba(255,255,255,0.1));
  background: var(--bg-glass, rgba(15,23,42,0.8));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

html[data-theme="light"] .diff-modal-panel .page-context-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.diff-modal-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.diff-modal-summary-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: hsla(220, 30%, 10%, 0.6);
  border-bottom: 1px solid var(--border-glass, rgba(255,255,255,0.08));
  flex-wrap: wrap;
}

html[data-theme="light"] .diff-modal-summary-bar {
  background: #f1f5f9 !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

.diff-summary-stat {
  display: flex;
  flex-direction: column;
}

.diff-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #94a3b8);
  font-weight: 700;
}

html[data-theme="light"] .diff-stat-label {
  color: #64748b;
}

.diff-stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main, #f8fafc);
}

html[data-theme="light"] .diff-stat-value {
  color: #0f172a;
}

.diff-summary-filter {
  margin-left: auto;
}

.diff-tabs-nav {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem 0;
  background: hsla(220, 30%, 8%, 0.95);
  border-bottom: 1px solid var(--border-glass, rgba(255,255,255,0.08));
  overflow-x: auto;
}

html[data-theme="light"] .diff-tabs-nav {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

.diff-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 0.9rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

html[data-theme="light"] .diff-tab-btn {
  color: #64748b;
}

.diff-tab-btn:hover {
  color: var(--text-main, #ffffff);
}

html[data-theme="light"] .diff-tab-btn:hover {
  color: #0f172a;
}

.diff-tab-btn.active {
  color: var(--accent-cyan, #06b6d4) !important;
  border-bottom-color: var(--accent-cyan, #06b6d4) !important;
  font-weight: 700;
}

html[data-theme="light"] .diff-tab-btn.active {
  color: #0284c7 !important;
  border-bottom-color: #0284c7 !important;
}

.diff-modal-panel .page-context-header,
.diff-modal-summary-bar,
.diff-tabs-nav,
.diff-modal-footer {
  flex-shrink: 0;
}

.diff-modal-body {
  flex: 1 1 auto;
  flex-shrink: 1;
  min-height: 0 !important;
  /* Explicit cap so long alteration lists scroll above the footer
     (does not rely solely on flex height:0 quirks). */
  max-height: min(52vh, 560px);
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1.25rem 1.5rem;
  display: block;
  background: var(--bg-primary, #090d16);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: hsla(215, 18%, 55%, 0.85) hsla(220, 20%, 12%, 0.35);
}

.diff-modal-body > * {
  /* Keep injected cards in normal flow inside the scrollport */
  flex-shrink: 0;
}

.diff-modal-body::-webkit-scrollbar {
  width: 10px;
}

.diff-modal-body::-webkit-scrollbar-track {
  background: hsla(220, 20%, 12%, 0.45);
  border-radius: 8px;
  margin: 4px 0;
}

.diff-modal-body::-webkit-scrollbar-thumb {
  background: hsla(215, 18%, 55%, 0.75);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.diff-modal-body::-webkit-scrollbar-thumb:hover {
  background: hsla(215, 20%, 65%, 0.95);
  border: 2px solid transparent;
  background-clip: padding-box;
}

html[data-theme="light"] .diff-modal-body {
  background: #f8fafc !important;
  scrollbar-color: #64748b #e2e8f0;
}

html[data-theme="light"] .diff-modal-body::-webkit-scrollbar-track {
  background: #e2e8f0;
}

html[data-theme="light"] .diff-modal-body::-webkit-scrollbar-thumb {
  background: #94a3b8;
}

html[data-theme="light"] .diff-modal-body::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

@media (max-height: 700px) {
  .diff-modal-body {
    max-height: min(42vh, 360px);
  }
}

.diff-row-card {
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border-glass, rgba(255,255,255,0.08));
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  margin-bottom: 1rem;
}

.diff-row-card:last-child {
  margin-bottom: 0;
}

html[data-theme="light"] .diff-row-card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

.diff-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: hsla(220, 30%, 12%, 0.7);
  border-bottom: 1px solid var(--border-glass, rgba(255,255,255,0.08));
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main, #ffffff);
}

html[data-theme="light"] .diff-row-header {
  background: #f8fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

.diff-row-changes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
  padding: 0.85rem 1rem;
}

.diff-field-card {
  background: hsla(220, 30%, 10%, 0.8);
  border: 1px solid var(--border-glass, rgba(255,255,255,0.08));
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
}

html[data-theme="light"] .diff-field-card {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

.diff-field-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 0.4rem;
}

html[data-theme="light"] .diff-field-name {
  color: #64748b;
}

.diff-val-compare {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.84rem;
}

.diff-val-ai {
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  text-decoration: line-through;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
}

html[data-theme="light"] .diff-val-ai {
  color: #b91c1c;
  background: #fee2e2;
  border-color: #fca5a5;
}

.diff-val-editor {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-weight: 700;
  word-break: break-word;
  font-size: 0.84rem;
}

html[data-theme="light"] .diff-val-editor {
  color: #15803d;
  background: #dcfce7;
  border-color: #86efac;
}

.diff-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg-glass, rgba(15,23,42,0.8));
  border-top: 1px solid var(--border-glass, rgba(255,255,255,0.1));
}

html[data-theme="light"] .diff-modal-footer {
  background: #ffffff !important;
  border-top: 1px solid #e2e8f0 !important;
}

.diff-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted, #94a3b8);
}

html[data-theme="light"] .diff-empty-state {
  color: #64748b;
}


