/* ==========================================================================
   AverisTech Offering — MOD-OCR Vision Dashboard Design System
   Executive Light Theme — Palette Ufficiale AverisTech (Smeraldo & Turchese)
   ========================================================================== */

:root {
  /* Palette Ufficiale Brand AverisTech */
  --brand-emerald: #10b981;
  --brand-emerald-dark: #059669;
  --brand-emerald-light: #34d399;
  --brand-cyan: #06b6d4;
  --brand-cyan-dark: #0891b2;
  --brand-cyan-light: #22d3ee;
  --brand-teal: #0d9488;
  --brand-gradient: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  --brand-gradient-hover: linear-gradient(135deg, #059669 0%, #0891b2 100%);
  --brand-gradient-subtle: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(6, 182, 212, 0.08) 100%);

  /* Superfici & Canvas Light */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.90);
  --bg-glass-heavy: rgba(255, 255, 255, 0.98);

  /* Bordi & Divisori Light */
  --border-subtle: #e2e8f0;
  --border-card: #e2e8f0;
  --border-accent: rgba(6, 182, 212, 0.35);
  --border-glow: rgba(16, 185, 129, 0.3);

  /* Accenti Funzionali */
  --accent-cyan: #0891b2;
  --accent-emerald: #059669;
  --accent-blue: #2563eb;
  --accent-teal: #0d9488;

  /* Stati & Validazioni QA (Ottimizzati per Light Mode) */
  --success: #059669;
  --success-bg: rgba(16, 185, 129, 0.10);
  --success-border: rgba(16, 185, 129, 0.28);
  --warning: #d97706;
  --warning-bg: rgba(245, 158, 11, 0.10);
  --warning-border: rgba(245, 158, 11, 0.28);
  --danger: #dc2626;
  --danger-bg: rgba(239, 68, 68, 0.10);
  --danger-border: rgba(239, 68, 68, 0.28);
  --info: #0284c7;
  --info-bg: rgba(6, 182, 212, 0.10);
  --info-border: rgba(6, 182, 212, 0.28);

  /* Tipografia ad Alto Contrasto */
  --text-main: #0f172a;        /* Slate 900 */
  --text-secondary: #334155;   /* Slate 700 */
  --text-muted: #475569;       /* Slate 600 */
  --text-dim: #64748b;         /* Slate 500 */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Ombreggiature & Profondità Multi-Layer */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 2px 6px -1px rgba(0, 0, 0, 0.04), 0 1px 3px -1px rgba(0, 0, 0, 0.03), 0 0 0 1px #e2e8f0;
  --shadow-card-hover: 0 12px 24px -4px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03), 0 0 0 1px rgba(16, 185, 129, 0.25);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
  --shadow-glow-cyan: 0 4px 16px rgba(6, 182, 212, 0.25);
  --shadow-glow-emerald: 0 4px 16px rgba(16, 185, 129, 0.25);

  /* Transizioni */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 8%, rgba(16, 185, 129, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 90% 12%, rgba(6, 182, 212, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 50% 95%, rgba(16, 185, 129, 0.03) 0%, transparent 50%);
  background-attachment: fixed;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo-box {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 4px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.brand-logo-box:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-badge-mod {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: var(--brand-gradient);
  color: #ffffff;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(6, 182, 212, 0.25);
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-top: 1px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Tenant Selector Box */
.tenant-picker-box {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.4rem 0.85rem;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.tenant-picker-box:focus-within {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.tenant-picker-box label {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
}

.tenant-picker-box select,
.tenant-picker-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.tenant-picker-box select option {
  background: #ffffff;
  color: var(--text-main);
  padding: 0.5rem;
}

/* Rate Limit Pill */
.rate-limit-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 20px;
  padding: 0.35rem 0.9rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--brand-emerald-dark);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--brand-emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: pulseAnimation 2s infinite;
}

@keyframes pulseAnimation {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* App Container */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.75rem 2rem 4rem;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-gradient);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(16, 185, 129, 0.35);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.kpi-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gradient-subtle);
  color: var(--brand-emerald-dark);
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.kpi-detail {
  font-size: 0.76rem;
  color: var(--text-dim);
}

/* Tabs Navigation */
.tabs-navigation {
  display: flex;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.75rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--text-main);
  font-weight: 700;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand-gradient);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

/* Tab Contents */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Playground Layout */
.playground-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .playground-layout {
    grid-template-columns: 1fr;
  }
}

/* Ingestion Control Panel */
.ingestion-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-card);
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--bg-card-subtle);
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand-emerald);
  background: #f0fdfa;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.12);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  color: var(--brand-teal);
  transition: transform var(--transition-fast);
}

.dropzone:hover .dropzone-icon {
  transform: translateY(-2px);
}

.dropzone-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.dropzone-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.file-input-hidden {
  display: none;
}

/* File Selected Badge */
.file-selected-card {
  display: none;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}

.file-selected-card.visible {
  display: flex;
}

.file-info-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
}

.file-name-text {
  font-weight: 700;
  color: var(--brand-emerald-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.file-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.25rem;
  transition: color var(--transition-fast);
}

.file-remove-btn:hover {
  color: var(--danger);
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.form-select, .form-input {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select:focus, .form-input:focus {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.form-select option {
  background: #ffffff;
  color: var(--text-main);
}

/* Advanced Accordion */
.accordion-toggle {
  background: transparent;
  border: none;
  color: var(--brand-teal);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  transition: color var(--transition-fast);
}

.accordion-toggle:hover {
  color: var(--brand-emerald-dark);
}

.accordion-body {
  display: none;
  flex-direction: column;
  gap: 0.85rem;
  padding-top: 0.5rem;
}

.accordion-body.open {
  display: flex;
}

/* Submit Action Button */
.btn-primary {
  background: var(--brand-gradient);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  box-shadow: var(--shadow-glow-cyan);
  transition: all var(--transition-normal);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
  filter: brightness(1.04);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

/* Results Display Area */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Placeholder Empty State */
.empty-state-card {
  background: var(--bg-card);
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  padding: 4rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  box-shadow: var(--shadow-sm);
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 1rem;
  opacity: 0.4;
  color: var(--brand-teal);
}

/* Extraction Loading State */
.loading-scanner-card {
  display: none;
  background: var(--bg-card);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 16px;
  padding: 3rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.loading-scanner-card.active {
  display: block;
}

.scanner-beam {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand-emerald), var(--brand-cyan), transparent);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
  animation: scanBeam 2s infinite ease-in-out;
}

@keyframes scanBeam {
  0% { top: 0%; opacity: 0; }
  25% { opacity: 1; }
  75% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.spinner-ring {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(16, 185, 129, 0.15);
  border-top-color: var(--brand-emerald);
  border-radius: 50%;
  animation: spinRing 0.8s linear infinite;
  margin: 0 auto 1.25rem;
}

@keyframes spinRing {
  to { transform: rotate(360deg); }
}

/* Extracted Result Card */
.extracted-result-card {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.extracted-result-card.visible {
  display: block;
}

.result-card-header {
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.doc-primary-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.doc-badge {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge-invoice { background: rgba(6, 182, 212, 0.12); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.28); }
.badge-ddt { background: rgba(16, 185, 129, 0.12); color: var(--brand-emerald-dark); border: 1px solid rgba(16, 185, 129, 0.28); }
.badge-po { background: rgba(37, 99, 235, 0.12); color: var(--accent-blue); border: 1px solid rgba(37, 99, 235, 0.28); }

.doc-number-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.doc-date-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Scanned Document Viewer Panel & Split-View Mode */
.playground-layout.playground-split-mode {
  grid-template-columns: 1fr;
  transition: all 0.3s ease;
}

.playground-layout.playground-split-mode .upload-sidebar {
  display: none;
}

.split-view-wrapper {
  display: block;
  transition: all 0.3s ease;
}

.split-view-wrapper.split-active {
  display: grid;
  grid-template-columns: minmax(420px, 48%) minmax(460px, 52%);
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-primary);
  align-items: start;
}

@media (max-width: 1080px) {
  .split-view-wrapper.split-active {
    grid-template-columns: 1fr;
  }
}

.split-left-scanned-pane {
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 1rem;
  height: calc(100vh - 120px);
  min-height: 750px;
  display: flex;
  flex-direction: column;
}

.split-left-scanned-pane .scanned-viewer-bar {
  padding: 0.65rem 1rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.split-left-scanned-pane .scanned-viewer-body {
  flex: 1;
  height: calc(100% - 46px);
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: #0b1120;
}

.split-left-scanned-pane .scanned-iframe-viewer {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.split-right-data-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.split-view-wrapper.split-active .split-right-data-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.btn-action-icon.active {
  background: rgba(6, 182, 212, 0.15) !important;
  border-color: var(--accent-cyan) !important;
  color: var(--accent-cyan) !important;
}

/* Executive Key Metrics Ribbon (Data Fattura, Data Scadenza, N. Doc, PO) */
.doc-key-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-subtle);
}

@media (max-width: 900px) {
  .doc-key-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .doc-key-metrics-grid {
    grid-template-columns: 1fr;
  }
}

.metric-highlight-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.metric-highlight-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.metric-highlight-card.metric-card-due {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(135deg, #ffffff 0%, rgba(254, 243, 199, 0.25) 100%);
}

.metric-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.metric-card-val {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.metric-card-val.highlight-date {
  color: var(--brand-emerald-dark);
}

.metric-card-val.highlight-due {
  color: #d97706;
}

.metric-card-val.highlight-po {
  color: var(--accent-blue);
}

.metric-card-val.dimmed-val {
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
}

.metric-card-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  font-weight: 500;
}

/* Quality Assurance Metrics Banner */
.qa-banner {
  padding: 1.25rem 1.5rem;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
}

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

/* Circular Score Gauge */
.score-gauge-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.score-circle-svg {
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}

.score-circle-bg {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 4;
}

.score-circle-val {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dasharray 1s ease;
}

.score-text-label {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

/* QA Badges List */
.qa-badges-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.qa-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid transparent;
}

.qa-chip-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.qa-chip-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.qa-chip-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.qa-chip-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}

/* Parties Information Cards */
.parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border-subtle);
}

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

.party-box {
  padding: 1.25rem 1.5rem;
}

.party-box:first-child {
  border-right: 1px solid var(--border-subtle);
}

.party-type-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.party-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.party-tax {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.party-address {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Document Line Items Table */
.items-section {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.section-subtitle {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.data-table-container {
  overflow-x: auto;
}

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

.data-table th {
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.data-table th.sortable-th:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.data-table th.sortable-th.active-sort {
  background: rgba(6, 182, 212, 0.12);
  color: #0891b2;
}

.data-table th.sortable-th .sort-icon {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  opacity: 0.45;
  transition: all var(--transition-fast);
}

.data-table th.sortable-th.active-sort .sort-icon {
  opacity: 1;
  color: #0891b2;
  font-weight: 800;
}

.data-table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: #f0fdfa;
  color: var(--text-main);
}

.data-table .col-num {
  text-align: right;
  font-family: var(--font-mono);
}

.line-check-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.35rem;
}

/* Dedicated Financial Payment & Installments Section */
.financial-payment-section {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  background: #ffffff;
}

.payment-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
}

.payment-card-stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.stat-mini-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-mini-val {
  font-size: 1.05rem;
  line-height: 1.3;
}

.stat-mini-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

/* Totals & Financial Settlement Section */
.totals-section {
  padding: 1.5rem;
  background: var(--bg-card-subtle);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.payment-terms-box {
  flex: 1 1 340px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.payment-box-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}

.payment-terms-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.payment-term-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  gap: 0.5rem;
}

.term-label {
  color: var(--text-muted);
}

.term-val {
  color: var(--text-main);
  text-align: right;
}

.badge-due-highlight {
  font-weight: 700;
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.totals-summary-box {
  width: 340px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.totals-row.grand-total {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

.totals-row .val-num {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--brand-teal);
}

/* Raw JSON Accordion */
.raw-json-panel {
  padding: 1rem 1.5rem;
}

.raw-json-code {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #38bdf8;
  overflow-x: auto;
  max-height: 300px;
  display: none;
}

.raw-json-code.open {
  display: block;
}

/* Transactions Table View */
.transactions-view-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.tx-toolbar {
  padding: 1.25rem 1.5rem;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-input-box {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  width: 300px;
  gap: 0.5rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input-box:focus-within {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.search-input-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-size: 0.85rem;
  width: 100%;
}

.filter-chips-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  background: #f8fafc;
  color: var(--text-main);
}

.filter-btn.active {
  background: var(--success-bg);
  border-color: var(--brand-emerald);
  color: var(--brand-emerald-dark);
  font-weight: 700;
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.status-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.status-failed { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }

/* Table Action Buttons */
.btn-action-icon {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.btn-action-icon:hover {
  background: var(--brand-teal);
  color: #ffffff;
  border-color: var(--brand-teal);
}

/* Pagination Bar */
.pagination-bar {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card-subtle);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.page-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-page {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-page:hover:not(:disabled) {
  background: #f1f5f9;
}

.btn-page:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Modal / Drawer */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  width: 96vw;
  max-width: 1320px;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}

.modal-header {
  padding: 1.1rem 1.5rem;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.25rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--bg-body);
}

/* Source & Provenance Badges */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.25;
}

.source-received {
  background: rgba(16, 185, 129, 0.1);
  color: var(--brand-emerald-dark);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.source-fetched {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease;
}

.toast.toast-success { border-left: 4px solid var(--brand-emerald); }
.toast.toast-warning { border-left: 4px solid var(--warning); }
.toast.toast-danger { border-left: 4px solid var(--danger); }
.toast.toast-info { border-left: 4px solid var(--brand-cyan); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   Multi-Tenant Email & Cronjob Manager Styles
   ========================================================================== */

.email-manager-kpi-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.email-manager-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.email-manager-kpi-card .kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.email-manager-kpi-card .kpi-val {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--text-main);
  line-height: 1.2;
}

.email-accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.email-account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
  position: relative;
}

.email-account-card:hover {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  border-color: rgba(6, 182, 212, 0.4);
}

.email-account-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.email-account-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-heading);
  margin: 0;
  line-height: 1.3;
}

.email-account-address {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.cron-frequency-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.cron-active-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
  cursor: pointer;
}

.cron-paused-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-dim);
  border: 1px solid rgba(148, 163, 184, 0.25);
  cursor: pointer;
}

.provider-preset-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.provider-preset-btn:hover {
  background: rgba(6, 182, 212, 0.08);
  border-color: var(--brand-cyan);
  color: var(--brand-cyan-dark);
}

.provider-preset-btn.selected {
  background: var(--brand-emerald-dark);
  color: #ffffff;
  border-color: var(--brand-emerald-dark);
}

/* ==========================================================================
   Executive Main Hub Navigation (Top-Level Platform Switcher)
   ========================================================================== */

.main-hub-navigation {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.main-hub-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.main-hub-btn:hover {
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  transform: translateY(-2px);
}

.main-hub-btn.active {
  border-color: var(--brand-emerald);
  background: linear-gradient(180deg, #ffffff 0%, rgba(16, 185, 129, 0.03) 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.12);
}

.main-hub-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--brand-gradient);
  border-radius: 14px 14px 0 0;
}

.main-hub-btn .hub-icon {
  font-size: 1.7rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.main-hub-btn .hub-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.main-hub-btn .hub-subtitle {
  font-size: 0.76rem;
  color: var(--text-dim);
  line-height: 1.35;
}

/* Sub-nav inside sections */
.sub-nav-bar {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.sub-nav-btn {
  background: transparent;
  border: none;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0.65rem 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.sub-nav-btn:hover {
  color: var(--text-main);
}

.sub-nav-btn.active {
  color: var(--brand-emerald-dark);
  border-bottom-color: var(--brand-emerald-dark);
  font-weight: 700;
}

/* Showcase Module Card */
.showcase-module-card {
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
  border-radius: 14px;
  padding: 3rem 2rem;
  text-align: center;
  max-width: 680px;
  margin: 2rem auto;
}

.hub-section {
  display: none;
}

.hub-section.active {
  display: block;
  animation: fadeInHub 0.2s ease;
}

.module-view {
  display: none;
}

.module-view.active {
  display: block;
}

.connector-view {
  display: none;
}

.connector-view.active {
  display: block;
}

.badge-subtle {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-subtle-indigo {
  background: rgba(99, 102, 241, 0.15);
  color: #4f46e5;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.badge-subtle-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-subtle-emerald {
  background: rgba(16, 185, 129, 0.15);
  color: var(--brand-emerald-dark);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.ocr-tab-content {
  display: none;
}

.ocr-tab-content.active {
  display: block;
}

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

/* ==========================================================================
   Header User Profile & Logout Box
   ========================================================================== */
.user-profile-header-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.user-icon {
  font-size: 0.9rem;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.user-role-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 12px;
  text-transform: uppercase;
  background: rgba(16, 185, 129, 0.15);
  color: var(--brand-emerald-dark);
}

.user-role-badge.role-client {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

.btn-logout {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

/* ==========================================================================
   Login Screen Overlay (Glassmorphism & Executive Branding)
   ========================================================================== */
.login-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 20%, rgba(13, 148, 136, 0.12) 0%, rgba(15, 23, 42, 0.75) 100%), rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeInHub 0.25s ease;
}

.login-card {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: 2.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
}

.login-brand-header {
  text-align: center;
}

.login-brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  margin: 0 auto 0.75rem auto;
}

.login-brand-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 0.25rem 0;
}

.login-brand-subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0;
}

.login-error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  display: none;
}

.login-error-banner.show {
  display: block;
}

.login-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-input-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.login-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-wrapper input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.88rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

.login-input-wrapper input:focus {
  border-color: var(--brand-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.btn-toggle-password {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 0.2rem;
}

.btn-login-submit {
  background: var(--brand-gradient);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: var(--font-heading);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.btn-login-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Quick Access Pills */
.quick-access-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quick-access-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quick-access-pills-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn-quick-pill {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.btn-quick-pill:hover {
  border-color: var(--brand-emerald);
  background: rgba(16, 185, 129, 0.05);
  color: var(--brand-emerald-dark);
}

/* ============================================================================
   IMPERSONATION BANNER & CONTROLS
   ============================================================================ */
.tenant-picker-box select optgroup {
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg-card-subtle);
  padding: 0.35rem 0.2rem;
}

.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(6, 182, 212, 0.12) 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  border-radius: 12px;
  padding: 0.85rem 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.08);
  gap: 1.25rem;
  animation: bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bannerSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.impersonation-banner-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.impersonation-banner-icon {
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 158, 11, 0.2);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}

.impersonation-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.impersonation-banner-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.impersonation-badge {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  background: #d97706;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.3);
}

.impersonation-subject {
  font-size: 0.88rem;
  color: var(--text-main);
}

.impersonation-subject strong {
  color: #b45309;
}

.impersonation-subject code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: #b45309;
}

.impersonation-banner-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.btn-exit-impersonation {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #1e293b;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0.6rem 1.15rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all var(--transition-fast);
}

.btn-exit-impersonation:hover {
  background: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   ROLE & PERMISSION MATRIX (GESTIONE RUOLI & COSA PUÒ FARE / VEDERE)
   ========================================================================== */

.role-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.role-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.35rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.role-card:hover {
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-2px);
}

.role-card.role-admin {
  border-left: 4px solid #8b5cf6;
}

.role-card.role-client-admin {
  border-left: 4px solid var(--accent-cyan);
}

.role-card.role-operator {
  border-left: 4px solid var(--brand-emerald);
}

.role-card.role-auditor {
  border-left: 4px solid #f59e0b;
}

.role-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.role-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.role-id-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
}

.role-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 1rem;
  min-height: 40px;
}

.role-stats-strip {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card-subtle);
  border-radius: 8px;
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.role-stats-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.role-stats-item strong {
  color: var(--text-main);
  font-family: var(--font-mono);
}

.role-pills-container {
  margin-bottom: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.role-pill-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.role-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.perm-pill {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 500;
}

.perm-pill.active-see {
  background: rgba(16, 185, 129, 0.1);
  color: var(--brand-emerald-dark);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.perm-pill.active-do {
  background: rgba(6, 182, 212, 0.1);
  color: #0284c7;
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.perm-pill.disabled-perm {
  background: rgba(148, 163, 184, 0.08);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
  text-decoration: line-through;
  opacity: 0.7;
}

.role-actions-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.85rem;
}

/* Permission Matrix Toggle Card inside Modal */
.perm-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.perm-toggle-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.95rem;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.perm-toggle-card:hover {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.02);
}

.perm-toggle-card.checked {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.04);
}

.perm-toggle-card input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--brand-emerald);
  width: 17px;
  height: 17px;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.perm-card-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.25;
  margin-bottom: 0.2rem;
}

.perm-card-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.35;
}






