/* ==========================================================================
   ClinOps365 PolicyHub - Enterprise Policy & Procedure Management System
   Inspired by RLDatix PolicyStat Standards | Clinical & Corporate Governance
   ========================================================================== */

:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-dark: #075985;
  --secondary: #0f766e;
  --secondary-light: #ccfbf1;
  --accent: #2563eb;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface: #f1f5f9;
  --bg-subtle: #f8fafc;
  
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-dark: #94a3b8;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-inverse: #ffffff;
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;
  
  --draft: #8b5cf6;
  --draft-bg: #f5f3ff;
  --draft-border: #ddd6fe;
  --draft-text: #5b21b6;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ==========================================================================
   Top Governance Bar & Main Header
   ========================================================================== */
.top-gov-bar {
  background: #091e2f;
  color: #94a3b8;
  font-size: 0.76rem;
  padding: 6px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gov-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: 0.72rem;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  display: inline-block;
}

.top-gov-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-gov-links a {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.top-gov-links a:hover {
  color: #ffffff;
}

.app-header {
  background: #0e2942;
  color: #ffffff;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.brand-text h1 {
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-sub {
  font-size: 0.78rem;
  color: #94a3b8;
  display: block;
}

.badge-system {
  font-size: 0.68rem;
  background: rgba(14, 165, 233, 0.25);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #7dd3fc;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.role-switcher-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 12px;
  border-radius: var(--radius-md);
}

.role-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0284c7;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.role-details {
  display: flex;
  flex-direction: column;
}

.role-user-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: #ffffff;
}

.role-select {
  background: transparent;
  color: #38bdf8;
  border: none;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.role-select option {
  background: #0f172a;
  color: #ffffff;
}

/* ==========================================================================
   Primary Navigation Tabs Bar
   ========================================================================== */
.tabs-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 71px;
  z-index: 30;
}

.tabs-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.nav-tabs {
  display: flex;
  list-style: none;
  gap: 4px;
}

.nav-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border: none;
  background: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.nav-tab-btn:hover {
  color: var(--primary);
  background-color: var(--bg-surface);
}

.nav-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background-color: transparent;
}

.tab-badge {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-muted);
}

.nav-tab-btn.active .tab-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.tab-badge.alert {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.quick-action-btns {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 0.94rem;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-surface);
  border-color: var(--border-dark);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-warning {
  background: var(--warning);
  color: #ffffff;
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary-light);
}

/* ==========================================================================
   Status Pills & Badges
   ========================================================================== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.status-pill.active {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.status-pill.in_review, .status-pill.in-review {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.status-pill.draft {
  background: var(--draft-bg);
  color: var(--draft-text);
  border: 1px solid var(--draft-border);
}

.status-pill.archived, .status-pill.retired {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.status-pill.overdue {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
  margin-right: 4px;
  margin-bottom: 4px;
}

.tag-pill.regulatory {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ==========================================================================
   Main Layout & Content Area
   ========================================================================== */
.main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

.view-section {
  display: none;
}

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

/* ==========================================================================
   Dashboard Metrics Strip
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: transform 0.15s, box-shadow 0.15s;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-info h3 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
  margin-bottom: 6px;
}

.metric-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.metric-icon.blue { background: #e0f2fe; color: #0284c7; }
.metric-icon.green { background: #ecfdf5; color: #10b981; }
.metric-icon.amber { background: #fffbeb; color: #f59e0b; }
.metric-icon.red { background: #fef2f2; color: #ef4444; }
.metric-icon.purple { background: #f5f3ff; color: #8b5cf6; }

/* ==========================================================================
   Filter & Search Toolbar
   ========================================================================== */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  font-size: 0.88rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-filter {
  padding: 8px 12px;
  font-size: 0.84rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.select-filter:focus {
  border-color: var(--primary);
}

/* ==========================================================================
   Data Table
   ========================================================================== */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: #f8fafc;
}

.policy-code-cell {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.policy-title-link {
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  display: block;
  font-size: 0.92rem;
  margin-bottom: 2px;
  cursor: pointer;
}

.policy-title-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.policy-meta-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.action-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
}

.action-menu-btn:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

/* ==========================================================================
   Document Editor & Structured Template Workspace
   ========================================================================== */
.editor-workspace {
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1200px) {
  .editor-workspace {
    grid-template-columns: 1fr;
  }
}

.outline-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: sticky;
  top: 130px;
  box-shadow: var(--shadow-sm);
}

.outline-title {
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.outline-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.outline-item a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
}

.outline-item a:hover {
  background: var(--bg-surface);
  color: var(--primary);
}

.outline-item.active a {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.document-sheet {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  position: relative;
}

/* Individual Standard Paper Sheet (Page 1 and Page 2) */
.document-page {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  padding: 44px 50px 36px 50px;
  margin-bottom: 24px;
  min-height: 980px;
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.document-page .page-content-flow {
  flex: 1;
}

/* Page Break Divider between Page 1 and Page 2 */
.document-page-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 32px 0;
  user-select: none;
}

.page-divider-line {
  flex: 1;
  height: 1px;
  background: #cbd5e1;
  border-top: 1px dashed #94a3b8;
}

.page-divider-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  background: #f1f5f9;
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Controlled Document Watermark */
.doc-watermark {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 4.5rem;
  font-weight: 900;
  color: rgba(2, 132, 199, 0.04);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 1;
}

.doc-watermark.draft {
  color: rgba(139, 92, 246, 0.06);
}

.doc-watermark.expired {
  color: rgba(239, 68, 68, 0.06);
}

.doc-header-block {
  margin-bottom: 26px;
  position: relative;
  z-index: 2;
}

/* Official St. Joseph Medical Center Header Box (Exact PDF Standard) */
.stjoseph-pdf-header-box {
  display: grid;
  grid-template-columns: 290px 1fr;
  border: 1px solid #000000;
  background: #ffffff;
  margin-bottom: 26px;
  box-sizing: border-box;
}

.stjoseph-header-left {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-right: 1px solid #000000;
  background: #ffffff;
}

.stj-logo-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.stj-clean-logo {
  max-height: 64px;
  max-width: 100%;
  width: auto;
  object-fit: contain;
  display: block;
}

.stjoseph-header-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stj-meta-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.35;
}

.stj-meta-grid tr {
  border-bottom: 1px solid #000000;
}

.stj-meta-grid tr:last-child {
  border-bottom: none;
}

.stj-meta-label {
  width: 175px;
  padding: 4px 10px;
  font-weight: 700;
  color: #000000;
  background: #ffffff;
  border-right: 1px solid #000000;
  white-space: nowrap;
}

.stj-meta-value {
  padding: 4px 12px;
  font-weight: 500;
  color: #000000;
  background: #ffffff;
}

/* St. Joseph PDF Footer Disclaimer Bar */
.stjoseph-pdf-footer-bar {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
  color: #000000;
  font-size: 0.72rem;
  line-height: 1.4;
}

.stj-disclaimer {
  font-style: italic;
  color: #000000;
  max-width: 95%;
}

.stj-page-count {
  font-size: 0.76rem;
  font-weight: normal;
  color: #000000;
}

/* Structured Policy Sections */
.policy-section-block {
  margin-bottom: 22px;
  position: relative;
  z-index: 2;
}

.section-heading-row {
  margin-bottom: 4px;
}

.section-heading-row h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #000000;
  margin: 0;
  font-family: inherit;
}

.rich-section-editor {
  border: 1px solid transparent;
  padding: 2px 4px;
  min-height: 28px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #000000;
  outline: none;
  background: transparent;
  transition: border-color 0.15s, background-color 0.15s;
}

.rich-section-editor[contenteditable="true"] {
  border: 1px dashed #0284c7;
  background: #ffffff;
  border-radius: 4px;
  padding: 8px 10px;
}

.rich-section-editor[contenteditable="true"]:focus {
  border-color: #0369a1;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.rich-section-editor p {
  margin: 0 0 8px 0;
  color: #000000;
}

/* St. Joseph Template Outline & Procedure Styles */
.procedure-outline {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #000000;
}

.procedure-level-0 {
  font-weight: 700;
  font-size: 1rem;
  color: #000000;
  margin: 8px 0 4px 0;
}

.procedure-level-1 {
  font-weight: 700;
  font-size: 1rem;
  color: #000000;
  margin: 14px 0 4px 0;
}

.procedure-num-list {
  margin: 4px 0 12px 28px;
  padding-left: 0;
  list-style-type: decimal;
}

.procedure-num-list > li {
  margin-bottom: 3px;
  color: #000000;
}

.procedure-sublist-alpha {
  margin: 4px 0 6px 24px;
  padding-left: 0;
  list-style-type: lower-alpha;
}

.procedure-sublist-alpha > li {
  margin-bottom: 3px;
  color: #000000;
}

/* St. Joseph Review and Approval Block */
.stj-review-approval-block {
  font-size: 0.95rem;
  color: #000000;
  line-height: 1.6;
}

.review-approval-intro {
  margin-bottom: 18px;
  color: #000000;
  font-weight: normal;
}

.stj-approval-field {
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.stj-approval-label {
  font-weight: 700;
  color: #000000;
}

.policy-callout {
  padding: 12px 16px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 0.88rem;
  border-left: 4px solid;
}

.policy-callout.warning {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}

.policy-callout.info {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0369a1;
}

.policy-callout.danger {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}

/* Sidebar Drawer (Properties, Workflow, History) */
.details-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 130px;
}

.sidebar-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.sidebar-panel-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.meta-field-group {
  margin-bottom: 12px;
}

.meta-field-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.meta-field-value {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ==========================================================================
   Visual Workflow Pipeline Builder & Interactive Steppers
   ========================================================================== */
.workflow-pipeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.wf-step-node {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: all 0.15s ease;
}

.wf-step-node.completed {
  border-left: 4px solid var(--success);
  background: #f0fdf4;
}

.wf-step-node.current {
  border-left: 4px solid #0284c7;
  background: #f0f9ff;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.wf-step-node.upcoming {
  border-left: 4px solid var(--border-medium);
  opacity: 0.85;
  background: #fafafa;
}

.step-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-order-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.76rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wf-step-node.completed .step-order-badge {
  background: var(--success);
  color: #ffffff;
}

.wf-step-node.current .step-order-badge {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.25);
  animation: pulseWorkflowDot 2s infinite;
}

@keyframes pulseWorkflowDot {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.5); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(2, 132, 199, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); }
}

.step-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
}

.step-assignee {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Department Workflow Grid & Pipeline Cards */
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.workflow-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.workflow-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
  transform: translateY(-2px);
}

.workflow-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.workflow-dept-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: #e0f2fe;
  color: #0369a1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.workflow-milestone-chain {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.milestone-chain-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}

.milestone-chain-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.milestone-chain-name {
  font-weight: 600;
  color: #1e293b;
  flex: 1;
}

.milestone-chain-assignee {
  font-size: 0.72rem;
  color: #64748b;
  background: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
}

/* Stepper Horizontal Timeline (for Policy Workflow Tracker Modal & Banner) */
.stepper-horizontal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  margin: 24px 0 20px 0;
  padding: 0 10px;
}

.stepper-horizontal::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 30px;
  right: 30px;
  height: 3px;
  background: #e2e8f0;
  z-index: 1;
}

.stepper-step {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
}

.stepper-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #cbd5e1;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.stepper-step.completed .stepper-circle {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.stepper-step.active .stepper-circle {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 0 5px rgba(2, 132, 199, 0.25);
  animation: pulseWorkflowDot 2s infinite;
}

.stepper-step.upcoming .stepper-circle {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #94a3b8;
}

.stepper-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #1e293b;
  max-width: 140px;
  line-height: 1.3;
}

.stepper-sub {
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 3px;
}

/* Workflow Stage Pill in Table */
.workflow-stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.workflow-stage-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.workflow-stage-pill.in-review {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.workflow-stage-pill.active {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.workflow-stage-pill.draft {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

.workflow-stage-pill.rejected {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* Milestone Builder in Modal */
.milestone-builder-item {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.milestone-builder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* ==========================================================================
   Redline Diff Viewer
   ========================================================================== */
.diff-container {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
}

.diff-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.diff-legend {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.legend-box.added { background: #bbf7d0; border: 1px solid #86efac; }
.legend-box.removed { background: #fecaca; border: 1px solid #fca5a5; }

.diff-content {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.7;
}

.diff-added {
  background-color: #dcfce7;
  color: #14532d;
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid #bbf7d0;
}

.diff-removed {
  background-color: #fee2e2;
  color: #991b1b;
  text-decoration: line-through;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid #fecaca;
}

/* ==========================================================================
   Ingestion Dropzone & Migration Wizard
   ========================================================================== */
.dropzone-box {
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-lg);
  background: #ffffff;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone-box:hover, .dropzone-box.dragover {
  border-color: var(--primary);
  background-color: #f0f9ff;
}

.dropzone-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  color: var(--primary);
  background: #e0f2fe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #0f172a;
}

.dropzone-desc {
  font-size: 0.84rem;
  color: #64748b;
  max-width: 460px;
  margin: 0 auto 16px;
}

.batch-queue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  margin-top: 16px;
}

.batch-queue-table th {
  background: #f1f5f9;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-medium);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.batch-queue-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
}

/* ==========================================================================
   Modal Dialogs & Sign-Off Overlays
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

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

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-medium);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.signature-pad-box {
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  height: 120px;
  background: #fdfdfd;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  position: relative;
  margin-top: 10px;
}

/* ==========================================================================
   Full Page Authentication & Login Overlay
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background-color: rgba(9, 30, 47, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.auth-card {
  background-color: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 36px 30px;
  margin: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   User Management & RBAC Module Styles
   ========================================================================== */
.user-admin-tabs-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.user-subtab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-subtab-btn:hover {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-dark);
}

.user-subtab-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: var(--shadow-sm);
}

.user-avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: #e0f2fe;
  color: #0284c7;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #bae6fd;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.user-role-badge.superadmin {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fbbf24;
  border: 1px solid #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
  font-weight: 800;
}

.user-role-badge.admin {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.user-role-badge.workflow_manager {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.user-role-badge.policy_owner {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.user-role-badge.approver {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.user-role-badge.reader {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.perm-pill-tag {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin: 2px 2px 2px 0;
  font-weight: 600;
  border: 1px solid #e2e8f0;
}

.perm-pill-tag.active-perm {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.action-btn-circle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 4px;
}

.action-btn-circle:hover {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-dark);
}

.action-btn-circle.delete-btn:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* ==========================================================================
   Print Stylesheet (Official Document Watermarks & Layout)
   ========================================================================== */
@media print {
  .top-gov-bar, .app-header, .tabs-bar, .toolbar-card, .outline-sidebar, .details-sidebar, .quick-action-btns, .btn, .document-page-separator {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }

  .main-content {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .editor-workspace {
    display: block !important;
  }

  .document-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
  }

  .document-page {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: auto !important;
    page-break-inside: avoid;
  }

  .sheet-page-2, .document-page.page-2 {
    break-before: page !important;
    page-break-before: always !important;
  }

  .doc-watermark {
    opacity: 0.12 !important;
  }
}
