    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap');

    :root {
      /* ── Core Dark Palette ── */
      --primary: #0B1120;
      --primary-light: #111827;
      --secondary: #D4A853;
      --secondary-hover: #C49A48;
      --accent: #1a2332;
      --light-blue: #0B1120;
      --surface: #111827;
      --surface-elevated: #1a2332;
      --surface-hover: #1e293b;
      --surface-input: #0f1729;

      /* ── Text ── */
      --text: #F1F5F9;
      --text-light: #94A3B8;
      --text-muted: #64748B;
      --text-faint: #475569;

      /* ── Borders ── */
      --border: rgba(255,255,255,0.06);
      --border-light: rgba(255,255,255,0.04);
      --border-focus: rgba(212, 168, 83, 0.5);

      /* ── Gold Accents ── */
      --gold: #D4A853;
      --gold-light: #E8C97A;
      --gold-muted: rgba(212, 168, 83, 0.15);
      --gold-border: rgba(212, 168, 83, 0.25);

      /* ── Semantic ── */
      --success: #34D399;
      --success-bg: rgba(52,211,153,0.1);
      --success-border: rgba(52,211,153,0.2);
      --error: #F87171;
      --error-bg: rgba(248,113,113,0.1);
      --error-border: rgba(248,113,113,0.2);
      --warning: #FBBF24;
      --warning-bg: rgba(251,191,36,0.1);
      --warning-border: rgba(251,191,36,0.2);
      --info: #60A5FA;
      --info-bg: rgba(96,165,250,0.1);
      --info-border: rgba(96,165,250,0.2);

      /* ── Typography ── */
      --font-heading: 'Playfair Display', Georgia, serif;
      --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

      /* ── Shadows ── */
      --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
      --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
      --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
      --shadow-gold: 0 0 20px rgba(212,168,83,0.08);
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      font-family: var(--font-body);
      line-height: 1.6;
      color: var(--text);
      background: var(--primary);
      min-height: 100vh;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

    /* ═══ HERO / LANDING ═══ */
    .hero-section {
      background: linear-gradient(135deg, var(--primary) 0%, #0f1a2e 100%);
      color: white; padding: 80px 0; text-align: center;
    }
    .logo {
      width: 80px; height: 80px; margin: 0 auto 30px;
      display: flex; align-items: center; justify-content: center;
    }
    .logo svg, .logo img { width: 100%; height: 100%; object-fit: contain; }
    .brand-logo svg, .brand-logo img { width: 100%; height: 100%; object-fit: contain; }
    .hero-section h1 {
      font-family: var(--font-heading); font-size: 3rem;
      font-weight: 700; margin-bottom: 10px; color: var(--text);
    }
    .hero-section h2 {
      font-family: var(--font-body); font-size: 1.5rem;
      font-weight: 400; margin-bottom: 20px; color: var(--text-light);
    }
    .tagline { font-size: 1.1rem; color: var(--text-muted); }

    .main-section { background: var(--primary); min-height: 70vh; padding: 80px 20px; }
    .container { max-width: 1200px; margin: 0 auto; }
    .screen { display: none; }
    .screen.active { display: block; }

    /* ═══ ROLE SELECTION ═══ */
    .role-selection {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
      gap: 40px; max-width: 800px; margin: 0 auto;
    }
    .role-card {
      background: var(--surface); border-radius: 16px; padding: 40px 30px;
      text-align: center; box-shadow: var(--shadow-md);
      cursor: pointer; transition: all 0.3s ease;
      border: 1px solid var(--border);
    }
    .role-card:hover {
      transform: translateY(-5px); box-shadow: var(--shadow-lg);
      border-color: var(--gold-border);
    }
    .role-icon {
      width: 80px; height: 80px;
      background: linear-gradient(135deg, var(--gold), var(--gold-light));
      border-radius: 16px; margin: 0 auto 25px;
      display: flex; align-items: center; justify-content: center;
      font-size: 32px; color: var(--primary);
    }
    .role-card h3 {
      font-family: var(--font-heading); font-size: 1.5rem;
      font-weight: 600; color: var(--text); margin-bottom: 15px;
    }
    .role-card p { color: var(--text-light); line-height: 1.6; }

    /* ═══ FORMS (Login / Registration) ═══ */
    .form-container {
      max-width: 600px; margin: 0 auto; background: var(--surface);
      border-radius: 16px; box-shadow: var(--shadow-lg);
      overflow: hidden; border: 1px solid var(--border);
    }
    .form-header {
      background: var(--surface-elevated); color: var(--text);
      padding: 30px; text-align: center; border-bottom: 1px solid var(--border);
    }
    .form-header h2 {
      font-family: var(--font-heading); font-size: 1.8rem;
      font-weight: 600; margin-bottom: 10px; color: var(--text);
    }
    .progress-indicator { display: flex; justify-content: center; gap: 10px; margin-top: 25px; }
    .step {
      width: 40px; height: 40px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-weight: 600; font-size: 0.9rem; transition: all 0.3s ease;
      border: 2px solid var(--border); color: var(--text-muted);
    }
    .step.active { background: var(--gold); border-color: var(--gold); color: var(--primary); }
    .step.done { background: var(--success); border-color: var(--success); color: white; }
    .form-body { padding: 40px; }
    .form-panel { display: none; }
    .form-panel.active { display: block; }
    .form-group { margin-bottom: 25px; }
    .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
    .form-group label {
      display: block; margin-bottom: 8px; font-weight: 500;
      color: var(--text-light); font-size: 0.85rem;
      text-transform: uppercase; letter-spacing: 0.3px;
    }
    .form-group input, .form-group select, .form-group textarea {
      width: 100%; padding: 12px 16px;
      border: 1px solid var(--border);
      border-radius: 8px; font-size: 1rem;
      transition: all 0.2s ease;
      font-family: var(--font-body);
      background: var(--surface-input);
      color: var(--text);
    }
    .form-group textarea { resize: vertical; min-height: 80px; }
    .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
      outline: none; border-color: var(--gold);
      box-shadow: 0 0 0 3px var(--gold-muted);
    }
    .form-group input::placeholder, .form-group textarea::placeholder {
      color: var(--text-faint);
    }
    .form-nav {
      display: flex; justify-content: space-between; align-items: center; margin-top: 30px;
    }

    /* ═══ BUTTONS ═══ */
    .btn {
      padding: 10px 20px; border: none; border-radius: 8px;
      font-size: 0.95rem; font-weight: 600; cursor: pointer;
      transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 8px;
      font-family: var(--font-body);
    }
    .btn-primary {
      background: linear-gradient(135deg, var(--gold), var(--gold-light));
      color: var(--primary);
    }
    .btn-primary:hover {
      box-shadow: 0 4px 16px rgba(212,168,83,0.3);
      transform: translateY(-1px);
    }
    .btn-primary:disabled { background: var(--text-faint); color: var(--text-muted); cursor: not-allowed; transform: none; box-shadow: none; }
    .btn-secondary {
      background: transparent; color: var(--text-light);
      border: 1px solid var(--border);
    }
    .btn-secondary:hover {
      background: var(--surface-hover); color: var(--text);
      border-color: rgba(255,255,255,0.1);
    }

    /* ═══ ALERTS ═══ */
    .alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; display: none; font-size: 0.9rem; }
    .alert.visible { display: block; }
    .alert.success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
    .alert.error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }

    .spinner {
      width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3);
      border-radius: 50%; border-top-color: white; animation: spin 0.8s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .success-screen { text-align: center; padding: 60px 20px; }
    .success-icon {
      width: 80px; height: 80px; background: var(--success); border-radius: 50%;
      margin: 0 auto 30px; display: flex; align-items: center; justify-content: center;
      font-size: 36px; color: white;
    }
    .section-divider {
      border: none; border-top: 1px solid var(--border); margin: 25px 0;
    }
    .section-title {
      font-family: var(--font-heading); font-size: 1.1rem;
      font-weight: 600; color: var(--text);
      margin-bottom: 20px; padding-bottom: 8px;
      border-bottom: 2px solid var(--gold);
    }
    .login-link {
      text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 0.9rem;
    }
    .login-link a { color: var(--gold); text-decoration: none; font-weight: 600; }
    .login-link a:hover { text-decoration: underline; }

    /* ═══ DASHBOARD & POST-LOGIN ═══ */
    .dashboard-container { min-height: 100vh; background: var(--primary); }
    .dashboard-header {
      background: var(--surface); border-bottom: 1px solid var(--border);
      padding: 0; position: sticky; top: 0; z-index: 100;
      height: 64px;
      backdrop-filter: blur(12px);
    }
    .dashboard-header-content {
      display: flex; justify-content: space-between; align-items: center;
      padding: 0 24px; height: 100%;
    }
    .dashboard-brand {
      display: flex; align-items: center; gap: 12px;
    }
    .dashboard-brand { display: flex; align-items: center; gap: 10px; }
    .dashboard-brand .brand-logo { width: 32px; height: 32px; }
    .dashboard-brand .brand-logo svg { width: 100%; height: 100%; }
    .dashboard-brand-text {
      font-family: var(--font-heading); font-size: 1.25rem;
      font-weight: 600; color: var(--text);
    }
    .dashboard-user {
      display: flex; align-items: center; gap: 15px;
    }
    .user-badge {
      display: flex; align-items: center; gap: 8px; padding: 6px 14px;
      background: var(--surface-elevated); border-radius: 8px;
      font-size: 0.85rem; border: 1px solid var(--border); color: var(--text);
    }
    .role-badge {
      display: inline-block; padding: 3px 8px; background: var(--gold-muted);
      color: var(--gold); border-radius: 4px; font-size: 0.7rem; font-weight: 600;
      text-transform: uppercase; letter-spacing: 0.8px;
    }
    .btn-logout {
      padding: 8px 16px; background: transparent; color: var(--text-light);
      border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
      font-size: 0.85rem; font-family: var(--font-body);
      transition: all 0.2s ease;
    }
    .btn-logout:hover { background: var(--surface-hover); color: var(--text); border-color: rgba(255,255,255,0.1); }

    .dashboard-content { padding: 28px 24px; max-width: 1400px; margin: 0 auto; }

    /* ═══ STATS CARDS ═══ */
    .stats-row {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 16px; margin-bottom: 28px;
    }
    .stat-card {
      background: var(--surface); padding: 20px 22px; border-radius: 12px;
      border: 1px solid var(--border); border-left: 3px solid var(--gold);
      transition: all 0.2s;
    }
    .stat-card:hover {
      border-color: var(--gold-border); box-shadow: var(--shadow-gold);
    }
    .stat-label {
      color: var(--text-muted); font-size: 0.8rem; font-weight: 500;
      text-transform: uppercase; letter-spacing: 0.5px;
    }
    .stat-value {
      font-family: var(--font-heading); font-size: 1.8rem;
      font-weight: 700; color: var(--text); margin-top: 8px;
    }
    .stat-card.processing { border-left-color: var(--warning); }
    .stat-card.completed { border-left-color: var(--success); }
    .stat-card.declined { border-left-color: var(--error); }

    /* ═══ DEALS SECTION ═══ */
    .deals-section-header {
      display: flex; justify-content: space-between; align-items: center;
      margin-bottom: 20px;
    }
    .deals-section-header h2 {
      font-family: var(--font-heading); font-size: 1.4rem;
      color: var(--text); font-weight: 600;
    }

    .deals-table-wrapper {
      background: var(--surface); border-radius: 12px;
      border: 1px solid var(--border); overflow-x: auto;
    }
    .deals-table {
      width: 100%; border-collapse: collapse; font-size: 0.9em;
    }
    .deals-table thead {
      background: var(--surface-elevated); border-bottom: 1px solid var(--border);
    }
    .deals-table th {
      padding: 14px 16px; text-align: left; font-weight: 600;
      color: var(--text-muted); font-size: 0.75rem;
      text-transform: uppercase; letter-spacing: 0.8px;
    }
    .deals-table td {
      padding: 14px 16px; border-bottom: 1px solid var(--border-light);
      font-size: 0.9rem; color: var(--text-light);
    }
    .deals-table tbody tr {
      transition: all 0.15s ease; cursor: pointer;
    }
    .deals-table tbody tr:hover { background: var(--surface-hover); }
    .deals-table tbody tr:hover td { color: var(--text); }
    .deal-ref {
      font-weight: 600; color: var(--gold); font-size: 0.82em;
      font-family: 'SF Mono', 'Fira Code', monospace;
    }
    .deal-address {
      color: var(--text-light); max-width: 200px; overflow: hidden;
      text-overflow: ellipsis; white-space: nowrap;
    }

    /* Pipeline table */
    .pipe-cell { font-size: 0.85em; line-height: 1.4; vertical-align: top; padding: 8px 6px !important; }
    .pipe-sub { color: var(--text-muted); font-size: 0.82em; }
    .pipe-empty { color: var(--text-faint); }
    .pipe-role { color: var(--text-muted); font-size: 0.8em; font-weight: 600; }
    .pipe-tag {
      display: inline-block; background: var(--surface-elevated); color: var(--text-light);
      font-size: 0.75em; padding: 1px 6px; border-radius: 3px; font-weight: 600;
    }

    .status-badge {
      display: inline-block; padding: 4px 10px; border-radius: 6px;
      font-size: 0.75rem; font-weight: 600; text-transform: capitalize;
    }
    .status-received { background: rgba(148,163,184,0.1); color: #94A3B8; }
    .status-processing { background: var(--warning-bg); color: var(--warning); }
    .status-completed { background: var(--success-bg); color: var(--success); }
    .status-declined { background: var(--error-bg); color: var(--error); }

    .empty-state {
      text-align: center; padding: 60px 20px; background: var(--surface);
      border-radius: 12px; border: 1px solid var(--border);
    }
    .empty-icon { font-size: 3rem; margin-bottom: 20px; opacity: 0.6; }
    .empty-state h3 { color: var(--text); margin-bottom: 10px; font-size: 1.3rem; font-family: var(--font-heading); }
    .empty-state p { color: var(--text-muted); margin-bottom: 30px; }

    /* ═══ DEAL DETAIL ═══ */
    .deal-detail-layout {
      display: block; max-width: 1440px; margin: 0 auto;
    }
    .deal-detail-container { width: 100%; padding: 0; }
    .deal-doc-sidebar { display: none !important; }

    /* ═══ DEAL SECTIONS (vertical stack) ═══ */
    .deal-section {
      background: var(--surface); border-radius: 12px; margin-top: 14px;
      border: 1px solid var(--border); overflow: hidden;
    }
    .deal-section.hidden-section { display: none !important; }
    .deal-section-header {
      padding: 14px 20px; display: flex; align-items: center; justify-content: space-between;
      cursor: pointer; user-select: none; transition: background 0.15s;
    }
    .deal-section-header:hover { background: var(--surface-hover); }
    .deal-section-chevron {
      font-size: 12px; color: var(--text-muted); transition: transform 0.2s, color 0.2s, background 0.2s;
      width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
      border-radius: 6px; background: var(--surface-elevated);
    }
    .deal-section-chevron.open { transform: rotate(90deg); color: var(--gold); background: var(--gold-muted); }
    .deal-section-body { border-top: 1px solid var(--border-light); }
    .deal-section-body.collapsed { max-height: 0; overflow: hidden; }

    /* Matrix editable field styles */
    .matrix-editable:focus { border-color: var(--gold) !important; box-shadow: 0 0 0 3px var(--gold-muted); }
    .matrix-editable:hover { border-color: var(--text-faint); }

    /* Parse progress bar animation */
    @keyframes matrixParseBar { from { width: 0%; } to { width: 95%; } }

    /* ═══ DOCUMENT PANEL ═══ */
    .doc-panel-header {
      background: var(--surface-elevated); color: var(--text); padding: 14px 16px;
      position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--border);
    }
    .doc-panel-title { font-weight: 700; font-size: 14px; color: var(--text); }
    .doc-panel-summary { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
    .doc-panel-sections { flex: 1; overflow-y: auto; }

    .doc-section { border-bottom: 1px solid var(--border-light); }
    .doc-section.greyed { opacity: 0.3; pointer-events: none; }
    .doc-section-header {
      display: flex; justify-content: space-between; align-items: center;
      padding: 8px 14px; cursor: pointer; font-size: 13px; transition: background 0.1s;
      border-left: 3px solid var(--border);
    }
    .doc-section-header:hover { background: var(--surface-hover); }
    .doc-section-header.expanded { background: rgba(96,165,250,0.05); border-left-color: var(--info); }
    .doc-section-header.approved { border-left-color: var(--success); }
    .doc-section-header.pending { border-left-color: var(--warning); }
    .doc-section-header.system { border-left-color: var(--text-faint); }

    .doc-section-label { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text); }
    .doc-section-badge {
      font-size: 9px; padding: 1px 6px; border-radius: 8px; font-weight: 600;
    }
    .doc-section-badge.ok { background: var(--success-bg); color: var(--success); }
    .doc-section-badge.pend { background: var(--warning-bg); color: var(--warning); }

    .doc-count-pill {
      background: var(--gold-muted); color: var(--gold); font-size: 10px; font-weight: 700;
      border-radius: 50%; width: 18px; height: 18px;
      display: inline-flex; align-items: center; justify-content: center;
    }

    .doc-section-body {
      padding: 4px 14px 10px; background: var(--surface-elevated); border-left: 3px solid var(--info);
    }
    .doc-file-row {
      display: flex; justify-content: space-between; align-items: center;
      padding: 5px 0; border-bottom: 1px solid var(--border-light); font-size: 12px;
    }
    .doc-file-row:last-child { border-bottom: none; }
    .doc-file-name { color: var(--text); font-weight: 500; }
    .doc-file-meta { color: var(--text-muted); font-size: 10px; }
    .doc-file-dl {
      background: none; border: 1px solid var(--border); border-radius: 4px;
      padding: 2px 8px; font-size: 11px; cursor: pointer; color: var(--gold);
    }
    .doc-file-dl:hover { background: var(--gold-muted); }

    .doc-upload-zone {
      display: flex; align-items: center; justify-content: center; gap: 4px;
      margin-top: 8px; padding: 6px; border: 1px dashed var(--border); border-radius: 6px;
      font-size: 11px; color: var(--text-muted); cursor: pointer; background: var(--surface);
    }
    .doc-upload-zone:hover { border-color: var(--gold); color: var(--gold); }

    .doc-empty { color: var(--text-faint); font-size: 12px; padding: 8px 0; text-align: center; font-style: italic; }

    .doc-panel-footer {
      border-top: 1px solid var(--border); padding: 8px 14px;
      font-size: 11px; color: var(--text-muted);
      display: flex; justify-content: space-between;
      position: sticky; bottom: 0; background: var(--surface);
    }

    @media (max-width: 1100px) {
      .deal-detail-layout { max-width: 100%; }
    }

    .breadcrumb {
      padding: 20px; background: var(--surface); border-bottom: 1px solid var(--border);
      display: flex; gap: 10px; align-items: center; font-size: 0.9rem; color: var(--text-muted);
    }
    .breadcrumb-link {
      color: var(--gold); cursor: pointer; text-decoration: none;
    }
    .breadcrumb-link:hover { text-decoration: underline; }

    .detail-panel {
      background: var(--surface); border-radius: 12px; margin: 20px;
      border: 1px solid var(--border);
    }
    .detail-header {
      padding: 25px; border-bottom: 1px solid var(--border);
      display: flex; justify-content: space-between; align-items: flex-start;
    }
    .detail-title {
      font-family: var(--font-heading); font-size: 1.5rem;
      font-weight: 700; color: var(--text);
    }
    .detail-meta {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
      gap: 20px; margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--border);
    }
    .detail-meta-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
    .detail-meta-value { font-weight: 600; color: var(--text); margin-top: 5px; }

    .detail-content { padding: 25px; }
    .detail-grid {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
      gap: 20px;
    }
    .detail-item-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
    .detail-item-value { font-weight: 500; color: var(--text); margin-top: 5px; word-break: break-word; }

    /* ═══ DOCUMENTS ═══ */
    .documents-section { margin-top: 30px; }
    .section-header {
      font-family: var(--font-heading); font-size: 1.1rem;
      font-weight: 600; color: var(--text);
      margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid var(--gold);
    }
    .documents-list { display: grid; gap: 12px; }
    .document-item {
      display: flex; justify-content: space-between; align-items: center;
      padding: 15px; background: var(--surface-elevated); border-radius: 8px;
      border: 1px solid var(--border);
    }
    .document-info {
      display: flex; gap: 15px; align-items: center; flex: 1;
    }
    .document-icon {
      width: 40px; height: 40px; background: var(--surface); border-radius: 6px;
      display: flex; align-items: center; justify-content: center;
      font-size: 1.2rem; border: 1px solid var(--border);
    }
    .document-name { font-weight: 600; color: var(--text); }
    .document-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
    .document-actions { display: flex; gap: 10px; }
    .btn-sm {
      padding: 6px 12px; font-size: 0.8rem; border: none; border-radius: 6px;
      cursor: pointer; transition: all 0.2s ease; font-family: var(--font-body);
    }
    .btn-download {
      background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: var(--primary);
    }
    .btn-download:hover { box-shadow: 0 2px 8px rgba(212,168,83,0.3); }

    .upload-zone {
      border: 2px dashed var(--gold-border); border-radius: 8px; padding: 40px;
      text-align: center; cursor: pointer; transition: all 0.3s ease;
      background: var(--gold-muted);
    }
    .upload-zone:hover {
      border-color: var(--gold); background: rgba(212,168,83,0.1);
    }
    .upload-zone.active {
      border-color: var(--gold); background: rgba(212,168,83,0.12);
    }
    .upload-icon { font-size: 2rem; margin-bottom: 10px; }
    .upload-text { color: var(--text); font-weight: 500; }
    .upload-subtext { color: var(--text-muted); font-size: 0.85rem; margin-top: 5px; }

    /* ═══ ADMIN PANEL ═══ */
    .admin-container { min-height: 100vh; background: var(--primary); }
    .admin-nav {
      background: var(--surface); border-bottom: 1px solid var(--border); padding: 0;
      display: flex; gap: 0;
    }
    .admin-nav-item {
      padding: 15px 25px; cursor: pointer; border: none; background: none;
      font-size: 0.9rem; font-weight: 500; color: var(--text-muted);
      border-bottom: 2px solid transparent; transition: all 0.2s ease;
      font-family: var(--font-body);
    }
    .admin-nav-item:hover { color: var(--text-light); }
    .admin-nav-item.active {
      color: var(--gold); border-bottom-color: var(--gold);
    }
    .admin-content { padding: 28px 24px; max-width: 1400px; margin: 0 auto; }
    .admin-tab { display: none; }
    .admin-tab.active { display: block; }

    .filter-bar {
      display: flex; gap: 15px; margin-bottom: 25px; flex-wrap: wrap;
      background: var(--surface); padding: 20px; border-radius: 8px;
      border: 1px solid var(--border);
    }
    .filter-group { display: flex; flex-direction: column; gap: 5px; }
    .filter-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
    .filter-group select {
      padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
      font-size: 0.85rem; background: var(--surface-input); color: var(--text);
      cursor: pointer; font-family: var(--font-body);
    }

    .analytics-cards {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 16px; margin-bottom: 28px;
    }
    .chart-container {
      background: var(--surface); padding: 25px; border-radius: 12px;
      border: 1px solid var(--border); margin-bottom: 20px;
    }
    .chart-title {
      font-family: var(--font-heading); font-size: 1.1rem;
      font-weight: 600; color: var(--text); margin-bottom: 20px;
    }
    .chart-bar-row {
      display: flex; align-items: center; gap: 15px; margin-bottom: 15px;
    }
    .chart-label { font-size: 0.85rem; color: var(--text-light); min-width: 80px; }
    .chart-bar {
      flex: 1; height: 30px; background: linear-gradient(90deg, var(--gold), var(--gold-light));
      border-radius: 4px; position: relative;
    }
    .chart-value {
      position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
      color: var(--primary); font-weight: 700; font-size: 0.85rem;
    }

    .activity-list {
      background: var(--surface); padding: 25px; border-radius: 12px;
      border: 1px solid var(--border);
    }
    .activity-item {
      display: flex; gap: 15px; padding-bottom: 15px; margin-bottom: 15px;
      border-bottom: 1px solid var(--border-light);
    }
    .activity-item:last-child { border-bottom: none; }
    .activity-dot {
      width: 10px; height: 10px; background: var(--gold); border-radius: 50%;
      margin-top: 6px; flex-shrink: 0;
    }
    .activity-text { color: var(--text-light); font-size: 0.9rem; }
    .activity-time { color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; }

    .notes-form {
      background: var(--surface-elevated); padding: 20px; border-radius: 8px;
      margin-top: 20px; border: 1px solid var(--border);
    }
    .notes-form textarea {
      width: 100%; padding: 12px; border: 1px solid var(--border);
      border-radius: 6px; font-size: 0.9rem; font-family: var(--font-body);
      min-height: 80px; background: var(--surface-input); color: var(--text);
    }

    /* ═══ TOAST ═══ */
    .toast {
      position: fixed; bottom: 20px; right: 20px; padding: 15px 20px;
      background: var(--success); color: var(--primary); border-radius: 8px;
      box-shadow: var(--shadow-lg); z-index: 1000; font-weight: 600;
      animation: slideIn 0.3s ease;
    }
    .toast.error { background: var(--error); color: white; }
    @keyframes slideIn {
      from { transform: translateX(400px); opacity: 0; }
      to { transform: translateX(0); opacity: 1; }
    }

    /* ═══ DEAL SUBMISSION TABS ═══ */
    .deal-tabs {
      display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid var(--border);
      overflow-x: auto;
    }
    .deal-tab {
      padding: 12px 18px; border: none; background: none; cursor: pointer;
      font-size: 0.85rem; font-weight: 500; color: var(--text-muted);
      border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
      font-family: var(--font-body); transition: all 0.15s;
    }
    .deal-tab:hover { color: var(--text-light); }
    .deal-tab.active { color: var(--gold); border-bottom-color: var(--gold); font-weight: 600; }
    .deal-tab-panel { display: none; }
    .deal-tab-panel.active { display: block; }

    /* ═══ DEAL DETAIL TABS ═══ */
    .detail-tabs-nav {
      background: var(--surface); border-radius: 12px; padding: 16px 20px; margin-bottom: 20px;
      border: 1px solid var(--border); overflow-x: auto;
    }
    .detail-tabs-group {
      display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 8px;
    }
    .detail-tabs-group:last-child { margin-bottom: 0; }
    .detail-tabs-label {
      font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
      color: var(--text-muted); margin-right: 8px; min-width: 100px;
    }
    .detail-tab {
      padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px;
      background: var(--surface-elevated); cursor: pointer; font-size: 0.8rem; color: var(--text-light);
      transition: all 0.15s; font-family: var(--font-body);
    }
    .detail-tab:hover { background: var(--surface-hover); border-color: var(--gold-border); color: var(--text); }
    .detail-tab.active { background: var(--gold); color: var(--primary); border-color: var(--gold); font-weight: 600; }
    .detail-tab-panel { display: none; }
    .detail-tab-panel.active { display: block; }

    .phase2-group { border-top: 1px dashed var(--border); padding-top: 10px; }
    .phase2-tab.locked { opacity: 0.4; cursor: not-allowed; background: var(--surface-elevated); }
    .lock-icon { font-size: 0.75rem; }
    .lock-icon-large { font-size: 40px; display: block; margin-bottom: 10px; }
    .phase2-notice {
      text-align: center; padding: 50px 20px; color: var(--text-muted);
    }
    .phase2-notice h3 { color: var(--text); margin-bottom: 10px; font-family: var(--font-heading); }
    .phase2-tab.unlocked { border-color: var(--success); }

    /* ═══ STAGE BADGES ═══ */
    .stage-badge {
      display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 0.72rem;
      font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
    }
    .stage-badge.stage-draft { background: rgba(251,191,36,0.1); color: #FBB724; border: 1px dashed rgba(251,191,36,0.4); }
    .stage-badge.stage-received { background: rgba(148,163,184,0.1); color: #94A3B8; }
    .stage-badge.stage-assigned { background: var(--warning-bg); color: var(--warning); }
    .stage-badge.stage-dip_issued { background: var(--info-bg); color: var(--info); }
    .stage-badge.stage-info_gathering { background: rgba(251,146,60,0.1); color: #FB923C; }
    .stage-badge.stage-ai_termsheet { background: rgba(236,72,153,0.1); color: #EC4899; }
    .stage-badge.stage-fee_pending { background: var(--warning-bg); color: var(--warning); }
    .stage-badge.stage-fee_paid { background: var(--success-bg); color: var(--success); }
    .stage-badge.stage-underwriting { background: rgba(168,85,247,0.1); color: #A855F7; }
    .stage-badge.stage-bank_submitted { background: rgba(168,85,247,0.1); color: #A855F7; }
    .stage-badge.stage-bank_approved { background: var(--success-bg); color: var(--success); }
    .stage-badge.stage-borrower_accepted { background: var(--info-bg); color: var(--info); }
    .stage-badge.stage-legal_instructed { background: var(--info-bg); color: var(--info); }
    .stage-badge.stage-completed { background: var(--success-bg); color: var(--success); font-weight: 700; }
    .stage-badge.stage-declined { background: var(--error-bg); color: var(--error); }
    .stage-badge.stage-withdrawn { background: rgba(148,163,184,0.1); color: #94A3B8; }
    /* Legacy stages */
    .stage-badge.stage-dip { background: rgba(148,163,184,0.1); color: #94A3B8; }
    .stage-badge.stage-termsheet_sent { background: var(--warning-bg); color: var(--warning); }
    .stage-badge.stage-termsheet_signed { background: var(--success-bg); color: var(--success); }
    .stage-badge.stage-credit_review { background: rgba(168,85,247,0.1); color: #A855F7; }
    .stage-badge.stage-compliance_review { background: rgba(236,72,153,0.1); color: #EC4899; }
    .stage-badge.stage-approved { background: var(--success-bg); color: var(--success); }
    .stage-badge.stage-legal { background: var(--info-bg); color: var(--info); }
    .stage-badge.stage-funds_released { background: var(--success-bg); color: var(--success); font-weight: 700; }

    /* ═══ ROLE TAGS ═══ */
    .role-tag { display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
    .role-tag.role-admin { background: var(--gold-muted); color: var(--gold); }
    .role-tag.role-rm { background: var(--info-bg); color: var(--info); }
    .role-tag.role-credit { background: rgba(168,85,247,0.12); color: #A855F7; }
    .role-tag.role-compliance { background: rgba(236,72,153,0.12); color: #EC4899; }

    .onboarding-form { padding-top: 10px; }
    .onboarding-file { margin-top: 4px; }
    .form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

    /* ═══ SIDEBAR NAV ═══ */
    .sidebar-nav-item:hover {
      background: #1e293b !important;
      color: #F1F5F9 !important;
    }
    .sidebar-nav-item.active {
      background: rgba(212,168,83,0.15) !important;
      color: #D4A853 !important;
    }
    .sidebar-nav-item.active:hover {
      background: rgba(212,168,83,0.2) !important;
    }

    /* ═══ DIP FORM — force dark text on light background ═══ */
    .dip-light-form,
    .dip-light-form * {
      color: #1a1a2e !important;
    }
    .dip-light-form .dip-preserve-color {
      color: inherit !important;
    }
    .dip-light-form label { color: #374151 !important; }
    .dip-light-form h5 { color: #1e3a5f !important; }
    .dip-light-form input,
    .dip-light-form select,
    .dip-light-form textarea {
      color: #1a1a2e !important;
      background: #fff !important;
    }
    .dip-light-form input[readonly],
    .dip-light-form textarea[readonly] {
      background: #f9fafb !important;
      color: #374151 !important;
    }
    .dip-light-form th { color: #374151 !important; }
    .dip-light-form td { color: #1a1a2e !important; }
    .dip-light-form span[style*="color:#92400e"] { color: #92400e !important; }
    .dip-light-form span[style*="color:#166534"] { color: #166534 !important; }
    .dip-light-form span[style*="color:#991b1b"] { color: #991b1b !important; }
    .dip-light-form span[style*="color:#15803d"] { color: #15803d !important; }
    .dip-light-form button[style*="color:#166534"] { color: #166534 !important; }
    .dip-light-form button[style*="color:#991b1b"] { color: #991b1b !important; }
    .dip-light-form button[style*="color:white"] { color: white !important; }
    .dip-light-form button#btn-issue-dip { color: #ffffff !important; }
    .dip-light-form button[style*="background:#9ca3af"] { color: #ffffff !important; }
    .dip-light-form [style*="background:#dcfce7"] { color: #166534 !important; }
    .dip-light-form [style*="background:#fee2e2"] { color: #991b1b !important; }
    .dip-light-form [style*="background:#15803d"] { color: white !important; }
    .dip-light-form [style*="background:#e53e3e"] { color: white !important; }
    .dip-light-form [style*="background:#fef3c7"] { color: #92400e !important; }
    .dip-light-form [style*="background:#1e3a5f"] { color: #fff !important; }
    .dip-light-form [style*="background:#eff6ff"] { color: #1e40af !important; }
    .dip-light-form [style*="background:#e5e7eb"] { color: #6b7280 !important; }

    /* ═══ DIP PREVIEW CONTAINER (2026-04-21) ═══
       The preview injects the PDF's full HTML + <style> block into this container.
       The PDF's navy banners and brand headers rely on their own CSS (`color:#fff`
       on class selectors). Without the overrides below, the app's global
       `.dip-light-form * { color: #1a1a2e !important }` would force every element
       in the preview to dark text, making navy banners illegible. The rules below
       restore the PDF's intended colours ONLY inside #dip-preview-container. */
    #dip-preview-container .section-bar,
    #dip-preview-container .section-bar *,
    #dip-preview-container .brand,
    #dip-preview-container .brand *,
    #dip-preview-container .page-footer,
    #dip-preview-container .page-footer *,
    #dip-preview-container .ref-strip .badge { color: #ffffff !important; }
    #dip-preview-container .brand-tagline,
    #dip-preview-container .brand-right .issued { color: #c9a456 !important; }
    #dip-preview-container .title-bar h1,
    #dip-preview-container .sec-row .label strong,
    #dip-preview-container .party-name,
    #dip-preview-container .ref-strip .ref { color: #0f2a4a !important; }
    #dip-preview-container .status.req { color: #2e8f4e !important; background: #e5f3ea !important; }
    #dip-preview-container .title-bar .sub,
    #dip-preview-container .party-role,
    #dip-preview-container .parties-note,
    #dip-preview-container .page-footer .policies { color: #6b7280 !important; }
    /* Approve button inside .section-bar needs its inline colours preserved
       — button specifies color in inline style; add explicit exceptions. */
    #dip-preview-container .section-bar button[style*="background:#16a34a"] { color: #ffffff !important; }
    #dip-preview-container .section-bar button[style*="background:#ffffff"] { color: #166534 !important; }
    #dip-preview-container .section-bar .dip-approval-control span { color: inherit !important; }
    /* Waterfall "Net Advance to Borrower" total badge — navy background with
       white text; the global dark-text override was making it invisible. */
    #dip-preview-container .waterfall-row.total .amount { color: #ffffff !important; }

    /* ═══ RESPONSIVE ═══ */
    @media (max-width: 768px) {
      .dashboard-header-content { flex-direction: column; gap: 12px; }
      .dashboard-user { flex-direction: column; gap: 10px; }
      .form-row { grid-template-columns: 1fr; }
      .role-selection { grid-template-columns: 1fr; }
      .deals-table { font-size: 0.82rem; }
      .deals-table th, .deals-table td { padding: 10px; }
      .deal-address { max-width: 120px; }
      .filter-bar { flex-direction: column; }
      .admin-nav { flex-wrap: wrap; }
      .admin-nav-item { padding: 12px 15px; font-size: 0.85rem; }
    }

/* ───────────────────────────────────────────────────────
 * Native <select> dropdown — dark theme for <option> list
 * Fixes: browsers render open <option> list with default
 * white background against dark theme → unreadable.
 * Applies globally so every modal (Property, Borrower,
 * Financial, etc.) renders consistently.
 * ─────────────────────────────────────────────────────── */
select {
  color-scheme: dark;
}
select option {
  background-color: #1a2233;
  color: #F1F5F9;
  padding: 4px 8px;
}
select option:disabled {
  color: #64748B;
}
select option:hover,
select option:focus,
select option:active,
select option:checked {
  background-color: #D4A853 !important;
  color: #111 !important;
  font-weight: 600;
}

/* ───────────────────────────────────────────────────────
 * Matrix section colour coding — left borders on inner cards
 * Each section's expanded-content cards get a left border matching
 * the section's letter-icon colour, so analyst can visually identify
 * section/sub-section at a glance.
 *
 * Target selector explanation:
 *   #content-sN               — section N's expanded area
 *   [id^="detail-"]           — any detail-* wrapper (field row expand)
 *   > div > div               — the inner card (wrapper > padding-div > card)
 * ─────────────────────────────────────────────────────── */
#content-s1 [id^="detail-"] > div > div[style*="background:#111827"] {
  border-left: 3px solid #60A5FA; /* Borrower / KYC — blue (matches B icon) */
}
#content-s2 [id^="detail-"] > div > div[style*="background:#111827"] {
  border-left: 3px solid #D4A853; /* Financials — gold (matches F icon) */
}
#content-s3 [id^="detail-"] > div > div[style*="background:#111827"] {
  border-left: 3px solid #34D399; /* Property / Security — green (matches P icon) */
}
#content-s4 [id^="detail-"] > div > div[style*="background:#111827"] {
  border-left: 3px solid #A855F7; /* Loan Terms & Use of Funds — purple (matches L icon) */
}
#content-s5 [id^="detail-"] > div > div[style*="background:#111827"] {
  border-left: 3px solid #FB923C; /* Exit Strategy — orange (matches E icon) */
}
#content-s6 [id^="detail-"] > div > div[style*="background:#111827"] {
  border-left: 3px solid #94A3B8; /* Legal & Insurance — slate (matches LG icon) */
}
#content-s7 [id^="detail-"] > div > div[style*="background:#111827"] {
  border-left: 3px solid #D4A853; /* Commercial — gold (matches C icon) */
}
#content-s8 [id^="detail-"] > div > div[style*="background:#111827"] {
  border-left: 3px solid #60A5FA; /* Documents Issued — blue (matches D icon) */
}
