/* Idea Station Multi-Brand Dynamic Stylesheet & Mobile Responsive System */

:root {
  --brand-primary: #0f172a;
  --brand-accent: #2563eb;
  --brand-highlight: #38bdf8;
  --brand-bg: #f8fafc;
  --brand-surface: #ffffff;
  --brand-border: #e2e8f0;
  --brand-text-primary: #0f172a;
  --brand-text-muted: #64748b;
  --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--brand-bg);
  color: var(--brand-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* App Header & Brand Bar */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #ffffff;
  border-bottom: 1px solid var(--brand-border);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.nav-brand-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.nav-crumb {
  font-size: 0.85rem;
  color: var(--brand-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.btn-sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--brand-text-primary);
}

.brand-select-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-select-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.brand-dropdown {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-heading);
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  background-color: #ffffff;
  color: var(--brand-text-primary);
  cursor: pointer;
  outline: none;
  max-width: 180px;
  transition: all 0.2s ease;
}

.brand-dropdown:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--brand-border);
  color: var(--brand-text-primary);
}

.btn-outline:hover {
  background-color: var(--brand-surface);
}

.btn-primary {
  background-color: var(--brand-accent);
  color: #ffffff;
  border: 1px solid transparent;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

/* Layout */
.app-layout {
  display: flex;
  min-height: calc(100vh - 58px);
  position: relative;
}

/* Sidebar & Drawer */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
  backdrop-filter: blur(2px);
}

.sidebar {
  width: 320px;
  background-color: #ffffff;
  border-right: 1px solid var(--brand-border);
  padding: 1.25rem;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.sidebar-search-box {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.search-icon {
  position: absolute;
  left: 0.65rem;
  font-size: 0.8rem;
  color: var(--brand-text-muted);
  pointer-events: none;
}

.project-search-input {
  width: 100%;
  padding: 0.5rem 1.8rem 0.5rem 2rem;
  font-size: 0.825rem;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  background-color: #ffffff;
  color: var(--brand-text-primary);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.project-search-input:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.clear-search-btn {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--brand-text-muted);
  cursor: pointer;
  padding: 0.2rem;
}

.clear-search-btn:hover {
  color: var(--brand-text-primary);
}

.brand-filter-select {
  width: 100%;
  padding: 0.45rem 0.65rem;
  font-size: 0.775rem;
  font-weight: 600;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  background-color: var(--brand-surface);
  color: var(--brand-text-primary);
  cursor: pointer;
  outline: none;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.count-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  color: var(--brand-text-muted);
}

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-text-muted);
}

.project-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-card {
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  background-color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.project-card:hover {
  border-color: var(--brand-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.project-card.active {
  border-color: var(--brand-accent);
  background-color: #f8fafc;
  box-shadow: 0 0 0 1px var(--brand-accent);
}

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.project-card-title {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brand-text-primary);
  word-break: break-word;
  line-height: 1.25;
}

.brand-pill {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand-pill-nixxie-international { background: #fdf2f8; color: #be185d; border: 1px solid #fbcfe8; }
.brand-pill-nixxie { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.brand-pill-kart-drop { background: #fefce8; color: #a16207; border: 1px solid #fef08a; }
.brand-pill-neutral { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

.stage-badge-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-idea { background: #e0f2fe; color: #0369a1; }
.badge-nda { background: #fef08a; color: #854d0e; }
.badge-msa { background: #e0e7ff; color: #3730a3; }
.badge-quote { background: #dcfce7; color: #15803d; }
.badge-sow { background: #fef3c7; color: #b45309; }
.badge-cr { background: #ffedd5; color: #c2410c; }
.badge-prd { background: #f3e8ff; color: #7e22ce; }
.badge-spec { background: #ffe4e6; color: #be123c; }

.archived-accordion {
  border-top: 1px solid var(--brand-border);
  padding-top: 1rem;
}

.archived-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.archived-summary::-webkit-details-marker {
  display: none;
}

.archived-summary .sidebar-title::before {
  content: '▶ ';
  font-size: 0.65rem;
  display: inline-block;
  transition: transform 0.2s ease;
  margin-right: 0.25rem;
}

.archived-accordion[open] .archived-summary .sidebar-title::before {
  content: '▼ ';
}

.archived-compact-list {
  margin-top: 0.5rem;
  gap: 0.35rem;
}

.project-card.archived-compact {
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  opacity: 0.75;
  background-color: #fafafa;
}

/* Main Content Area (Centered Canvas / Paper Document Look) */
.main-content {
  flex: 1;
  padding: 2rem 2rem 4rem 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  background-color: #f1f5f9;
}

/* Stage Navigation Tabs */
.stage-tabs-container {
  width: 100%;
  max-width: 900px;
  margin-bottom: 1.25rem;
}

.stage-tabs-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 4px;
}

.stage-tab {
  padding: 0.55rem 1.1rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-text-muted);
  cursor: pointer;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--brand-border);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.stage-tab:hover {
  color: var(--brand-primary);
  border-color: #cbd5e1;
}

.stage-tab.active {
  color: #ffffff;
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.stage-tab-divider {
  display: flex;
  align-items: center;
  color: #cbd5e1;
  font-weight: 300;
  padding: 0 0.25rem;
  user-select: none;
}

.stage-tab.spec-tab {
  color: #64748b;
  font-size: 0.8rem;
}

.stage-tab.spec-tab.active {
  background-color: #334155;
  border-color: #334155;
  color: #ffffff;
}

/* Document Paper Sheet Container (Pixel Perfect A4 Simulation) */
.document-view {
  width: 100%;
  max-width: 900px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  padding: 3.5rem 4rem;
  margin-bottom: 3rem;
}

/* Brand Letterhead */
.brand-letterhead {
  padding-bottom: 1.75rem;
  margin-bottom: 2.25rem;
  border-bottom: 2px solid var(--brand-primary);
}

.letterhead-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}

.letterhead-logo {
  height: 48px;
  max-width: 240px;
  object-fit: contain;
}

.letterhead-name {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--brand-primary);
}

.letterhead-meta {
  text-align: right;
  font-size: 0.775rem;
  color: var(--brand-text-muted);
  line-height: 1.5;
}

.letterhead-tagline {
  font-size: 0.825rem;
  color: var(--brand-text-muted);
  margin-top: 0.4rem;
}

/* Document Content Body */
.doc-content-body {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #1e293b;
}

.doc-content-body h1 {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 800;
  color: #0f172a;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.doc-content-body h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

.doc-content-body h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.doc-content-body p {
  margin-bottom: 1rem;
}

.doc-content-body ul, .doc-content-body ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.doc-content-body li {
  margin-bottom: 0.4rem;
}

.doc-content-body blockquote {
  border-left: 4px solid var(--brand-accent);
  padding: 0.75rem 1.25rem;
  background-color: #f8fafc;
  border-radius: 0 8px 8px 0;
  margin: 1.25rem 0;
  color: #334155;
  font-style: italic;
}

.doc-content-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}

.doc-content-body th, .doc-content-body td {
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid #e2e8f0;
}

.doc-content-body th {
  background-color: #f8fafc;
  font-family: var(--font-heading);
  font-weight: 700;
  color: #0f172a;
}

.doc-content-body tr:nth-child(even) {
  background-color: #fcfcfd;
}

.doc-content-body pre {
  background-color: #0f172a;
  color: #f8fafc;
  padding: 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin: 1.5rem 0;
}

.doc-content-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background-color: #f1f5f9;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.doc-content-body pre code {
  background-color: transparent;
  padding: 0;
  border: none;
  color: inherit;
}

.mermaid {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.75rem 0;
  text-align: center;
}

/* Document Footer */
.brand-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.775rem;
  color: var(--brand-text-muted);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 6rem 2rem;
  max-width: 500px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.empty-state h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--brand-text-muted);
  font-size: 0.9rem;
}

/* Modals */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

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

.modal-dialog {
  background: #ffffff;
  border-radius: 12px;
  width: 90%;
  max-width: 540px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #64748b;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-desc {
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.5;
}

.signer-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.signer-card-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.input-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.input-field input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #334155;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   📱 Mobile & Tablet Breakpoints (< 768px)
   ========================================================================== */

@media (max-width: 768px) {
  .btn-sidebar-toggle {
    display: inline-flex;
  }

  .nav-crumb, .brand-select-label {
    display: none;
  }

  .brand-dropdown {
    max-width: 130px;
    font-size: 0.775rem;
    padding: 0.35rem 0.5rem;
  }

  .btn-action span.btn-text {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 55px;
    bottom: 0;
    left: 0;
    z-index: 95;
    transform: translateX(-100%);
    box-shadow: 4px 0 16px rgba(0,0,0,0.1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-content {
    padding: 1rem 0.75rem 3rem 0.75rem;
  }

  .document-view {
    padding: 1.75rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
  }

  .letterhead-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .letterhead-meta {
    text-align: left;
  }

  .input-row {
    grid-template-columns: 1fr;
  }
}


/* ==========================================================================
   📋 Frontmatter Metadata Panel & Legal Header
   ========================================================================== */
.doc-frontmatter-panel {
  background: linear-gradient(to bottom, #f8fafc, #ffffff);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  overflow: hidden;
  transition: all 0.2s ease;
}

.fm-collapsible-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background-color 0.15s;
}

.fm-collapsible-bar:hover {
  background: #f1f5f9;
}

.doc-frontmatter-panel.expanded .fm-collapsible-bar {
  border-bottom-color: #e2e8f0;
}

.fm-bar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.fm-toggle-chevron {
  font-size: 0.8rem;
  color: #64748b;
  transition: transform 0.2s ease;
  display: inline-block;
}

.doc-frontmatter-panel.expanded .fm-toggle-chevron {
  transform: rotate(90deg);
}

.fm-bar-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fm-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-fm-action {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.btn-fm-action:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-fm-primary {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.btn-fm-primary:hover {
  background: #0369a1;
  border-color: #0369a1;
  color: #ffffff;
}

.fm-collapsible-content {
  display: none;
  padding: 1.25rem 1.5rem;
}

.doc-frontmatter-panel.expanded .fm-collapsible-content {
  display: block;
}

/* Edit Mode Tabs & Form */
.fm-edit-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.5rem;
}

.fm-edit-tab {
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  border-radius: 6px;
}

.fm-edit-tab.active {
  background: #e2e8f0;
  color: #0f172a;
}

.fm-edit-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.fm-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fm-input-group label {
  font-size: 0.725rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fm-input-group input,
.fm-input-group select {
  padding: 6px 10px;
  font-size: 0.825rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
}

.fm-input-group input:focus,
.fm-input-group select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.fm-yaml-textarea {
  width: 100%;
  height: 220px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #0f172a;
  resize: vertical;
  line-height: 1.4;
  outline: none;
}

.fm-yaml-textarea:focus {
  border-color: #3b82f6;
  background: #ffffff;
}

.fm-edit-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.fm-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.fm-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.fm-doc-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.fm-meta-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.fm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.725rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fm-badge-version {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  font-family: var(--font-mono);
}

.fm-badge-ref {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-family: var(--font-mono);
}

.fm-badge-status {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.fm-badge-status.status-signed {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.fm-badge-status.status-active {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

.fm-badge-brand {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

.fm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  padding-top: 1rem;
}

.fm-section {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fm-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}

.fm-party-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.75rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.fm-party-name {
  font-weight: 700;
  color: #0f172a;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.fm-party-sub {
  color: #475569;
  font-size: 0.75rem;
}

.fm-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  padding: 3px 0;
  border-bottom: 1px dashed #f1f5f9;
}

.fm-detail-label {
  color: #64748b;
  font-size: 0.75rem;
}

.fm-detail-val {
  font-weight: 600;
  color: #1e293b;
  text-align: right;
}

.fm-tags-row {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f5f9;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.fm-tag-pill {
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* Awaiting Dispatch Banner */
.awaiting-dispatch-card {
  width: 100%;
  max-width: 900px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.awaiting-dispatch-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.awaiting-icon {
  font-size: 1.6rem;
}

.awaiting-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
}

.awaiting-subtitle {
  font-size: 0.775rem;
  color: #64748b;
  margin-top: 2px;
.btn-preset-pill {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.725rem;
  padding: 3px 8px;
  border-radius: 9999px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-preset-pill:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Billing Recommendation Banner */
.billing-recommend-banner {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.billing-recommend-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.billing-recommend-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #92400e;
}

.billing-recommend-subtitle {
  font-size: 0.775rem;
  color: #b45309;
  margin-top: 2px;
}

/* Billing Telemetry Card */
.billing-telemetry-container {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.billing-telemetry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.billing-telemetry-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.billing-recipient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.billing-recipient-email {
  font-weight: 600;
  color: #1e293b;
}

.billing-status-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.billing-status-opened {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.billing-status-sent {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}

/* ==========================================================================
   🖨️ Print & PDF Export Styles (A4 Pagination)
   ========================================================================== */

@page {
  size: A4 portrait;
  margin: 15mm;
}

/* User Profile Widget in Top Nav */
.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 3px 6px 3px 3px;
  transition: all 0.15s ease;
}

.user-profile-widget:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-size: 0.725rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.25);
}

.user-info-text {
  display: none;
}

.btn-logout-icon {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-logout-icon:hover {
  background: #e2e8f0;
  color: #dc2626;
}

/* Sidebar New Project Button */
.sidebar-action-bar {
  padding: 0.5rem 0 0.75rem 0;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 0.75rem;
}

.btn-new-project {
  width: 100%;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: all 0.15s ease;
}

.btn-new-project svg {
  stroke: #38bdf8;
  flex-shrink: 0;
}

.btn-new-project:hover {
  background: #1e293b;
  border-color: #1e293b;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.16);
  transform: translateY(-1px);
}

.btn-new-project:active {
  transform: translateY(0);
}

/* Stage Tabs Actions & New CR Button */
.stage-tabs-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
  padding-right: 0.25rem;
}

.btn-new-cr-tab {
  background: #ffffff;
  color: #b45309;
  border: 1px dashed #f59e0b;
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 0.775rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-new-cr-tab svg {
  stroke: #d97706;
}

.btn-new-cr-tab:hover {
  background: #fffbeb;
  border-style: solid;
  border-color: #d97706;
  color: #92400e;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.12);
}

/* Team Selection Cards in Login Modal */
.team-quick-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 1rem;
}

.team-select-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.team-select-card:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.team-select-card.active {
  background: #f0f9ff;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

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

.team-select-card.active .team-avatar {
  background: #0369a1;
}

.team-card-name {
  font-size: 0.775rem;
  font-weight: 700;
  color: #0f172a;
}

.team-card-role {
  font-size: 0.675rem;
  color: #64748b;
}

/* ============================================================================
   ❓ Help Button & Keyboard Shortcuts
   ============================================================================ */
.btn-help {
  color: var(--brand-text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-help svg {
  color: #0284c7;
}

.btn-help:hover {
  background: var(--brand-surface);
  border-color: #94a3b8;
  color: #0284c7;
}

.kbd-badge {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 0.675rem;
  background: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.2;
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

/* ============================================================================
   🚀 Welcome Launchpad (Empty State)
   ============================================================================ */
.launchpad-container {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  text-align: left;
}

.launchpad-hero {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.04), 0 8px 10px -6px rgba(0,0,0,0.03);
}

.launchpad-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.launchpad-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.launchpad-subtitle {
  font-size: 1rem;
  color: #475569;
  max-width: 680px;
  margin: 0 auto 1.75rem auto;
  line-height: 1.6;
}

.launchpad-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.launchpad-btn-lg {
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  border-radius: 10px;
}

.launchpad-stepper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stepper-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stepper-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  color: #0f172a;
}

.stepper-caption {
  font-size: 0.8rem;
  color: #64748b;
}

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

.stepper-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all 0.2s ease;
  position: relative;
}

.stepper-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 6px 16px -2px rgba(0,0,0,0.06);
}

.stepper-step-pill {
  align-self: flex-start;
  font-size: 0.675rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}

.stepper-icon {
  font-size: 1.75rem;
  margin-top: 2px;
}

.stepper-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.stepper-docs {
  font-size: 0.775rem;
  color: #0284c7;
  font-weight: 600;
}

.stepper-desc {
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
}

.launchpad-features-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.feature-chip {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chip-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.chip-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chip-content strong {
  font-size: 0.85rem;
  color: #0f172a;
}

.chip-content span {
  font-size: 0.775rem;
  color: #64748b;
  line-height: 1.45;
}

/* ============================================================================
   ❓ Help Modal & Knowledge Base
   ============================================================================ */
.help-modal-dialog {
  max-width: 920px;
  width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
}

.help-modal-header {
  border-bottom: 1px solid #e2e8f0;
  padding: 1.25rem 1.5rem;
}

.help-tabs-nav {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem 0 1.5rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
}

.help-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.help-tab-btn:hover {
  color: #0f172a;
}

.help-tab-btn.active {
  color: #0284c7;
  border-bottom-color: #0284c7;
  background: #ffffff;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.help-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.help-pane {
  display: none;
}

.help-section-intro {
  margin-bottom: 1.25rem;
}

.help-section-intro h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.help-section-intro p {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.5;
  margin: 0;
}

.help-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.help-guide-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.guide-badge {
  font-size: 0.675rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #0284c7;
  background: #e0f2fe;
  padding: 2px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

.help-guide-card h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.help-step-list {
  padding-left: 1.2rem;
  font-size: 0.8rem;
  color: #334155;
  line-height: 1.55;
  margin: 0;
}

.help-step-list li {
  margin-bottom: 4px;
}

.help-step-list ul {
  padding-left: 1.2rem;
  margin-top: 3px;
}

.help-callout-info {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.775rem;
  color: #166534;
  line-height: 1.45;
}

.help-callout-tip {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.825rem;
  color: #1e40af;
  line-height: 1.5;
}

.help-prompt-example {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-left: 3px solid #0284c7;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-style: italic;
  color: #1e293b;
  line-height: 1.45;
}

/* Document Catalog Grid */
.doc-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.doc-item-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: all 0.2s ease;
}

.doc-item-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.doc-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.doc-type-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.doc-type-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  font-family: var(--font-mono, monospace);
}

.doc-stage-badge {
  font-size: 0.675rem;
  color: #64748b;
  display: block;
}

.doc-sign-status {
  margin-left: auto;
  font-size: 0.675rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.doc-sign-status.can-sign {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.doc-sign-status.no-sign {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.doc-item-desc {
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.5;
  margin: 0;
  flex: 1;
}

.doc-item-meta {
  font-size: 0.725rem;
  color: #64748b;
  line-height: 1.5;
  background: #f8fafc;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
}

/* Workflow List */
.help-workflow-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.workflow-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.workflow-box-num {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #0284c7;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.workflow-box-content {
  flex: 1;
}

.workflow-box-content h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 6px 0;
}

.workflow-box-content p {
  font-size: 0.825rem;
  color: #475569;
  line-height: 1.5;
  margin: 0 0 6px 0;
}

.workflow-box-content ul {
  padding-left: 1.2rem;
  font-size: 0.8rem;
  color: #334155;
  line-height: 1.55;
  margin: 0;
}

.workflow-box-content li {
  margin-bottom: 3px;
}

/* Help Shortcuts Table */
.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.help-table th {
  background: #f8fafc;
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  color: #334155;
  border-bottom: 1px solid #e2e8f0;
}

.help-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #475569;
}

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

.help-table kbd {
  font-family: var(--font-mono, monospace);
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.75rem;
  color: #0f172a;
}

@media print {
  html, body {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt;
  }

  .top-navbar, .sidebar, .stage-tabs-container, #esign-status-container, .modal-backdrop, .toast-container {
    display: none !important;
  }

  .app-layout {
    display: block !important;
  }

  .main-content {
    padding: 0 !important;
    background: transparent !important;
    display: block !important;
  }

  .document-view {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }
}

