/* ── Directory Container ─────────────────────────────────── */
.directory-container { flex: 1; display: flex; flex-direction: column; background: white; overflow: hidden; height: 100%; }
.directory-header { display: flex; align-items: center; gap: 16px; padding: 16px 20px 12px; border-bottom: 1px solid #e2e8f0; background: #fafbfc; flex-shrink: 0; }
.directory-header h2 { font-size: 18px; font-weight: 700; color: #0f172a; margin: 0; }
.dir-stats { display: flex; gap: 16px; margin-left: 8px; }
.dir-stat { font-size: 12px; color: #64748b; }
.dir-stat b { color: #1e293b; font-weight: 700; font-size: 14px; }

.dir-search { padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 12px; width: 200px; outline: none; }
.dir-search:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.dir-btn { padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; transition: all 0.15s; }
.dir-btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #d1d5db; }
.dir-btn-secondary:hover { background: #e2e8f0; }
.dir-btn-primary { background: #2563eb; color: white; }
.dir-btn-primary:hover { background: #1d4ed8; }

/* ── Tabs ────────────────────────────────────────────────── */
.directory-tabs { display: flex; gap: 0; border-bottom: 1px solid #e2e8f0; padding: 0 20px; background: #fafbfc; flex-shrink: 0; }
.dir-tab { padding: 10px 20px; font-size: 13px; font-weight: 500; color: #64748b; cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; transition: all 0.15s; position: relative; }
.dir-tab:hover { color: #1e293b; }
.dir-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.dir-tab .tab-count { font-size: 10px; background: #e2e8f0; color: #475569; padding: 1px 6px; border-radius: 8px; margin-left: 6px; font-weight: 600; }
.dir-tab.active .tab-count { background: #dbeafe; color: #1d4ed8; }

/* ── Toolbar ─────────────────────────────────────────────── */
.dir-toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 20px; border-bottom: 1px solid #f1f5f9; background: white; flex-shrink: 0; }
.dir-toolbar label { font-size: 11px; color: #64748b; font-weight: 500; }
.dir-toolbar select { font-size: 11px; padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 4px; color: #1e293b; cursor: pointer; }

/* ── Grid ────────────────────────────────────────────────── */
.dir-grid-wrap { flex: 1; overflow: auto; }
.dir-grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.dir-grid thead th { position: sticky; top: 0; z-index: 2; background: #f8fafc; border-bottom: 2px solid #e2e8f0; padding: 8px 12px; text-align: left; font-weight: 600; color: #475569; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.dir-grid thead th:first-child { width: 36px; text-align: center; }
.dir-grid tbody td { padding: 7px 12px; border-bottom: 1px solid #f1f5f9; color: #1e293b; white-space: nowrap; }
.dir-grid tbody td:first-child { text-align: center; }
.dir-grid tbody tr:hover { background: #f0f7ff; }
.dir-grid tbody tr.selected { background: #dbeafe; }

/* ── Group Header Row ────────────────────────────────────── */
.dir-group-row { cursor: pointer; user-select: none; }
.dir-group-row td { background: #f1f5f9 !important; padding: 6px 12px !important; font-weight: 700; font-size: 12px; color: #334155; border-bottom: 1px solid #e2e8f0 !important; text-align: left !important; }
.dir-group-row .group-color { display: inline-block; width: 4px; height: 16px; border-radius: 2px; margin-right: 8px; vertical-align: middle; }
.dir-group-row .group-count { font-weight: 400; color: #64748b; font-size: 11px; margin-left: 6px; }
.dir-group-row .group-chevron { display: inline-block; transition: transform 0.2s; margin-right: 4px; font-size: 10px; color: #94a3b8; }
.dir-group-row.collapsed .group-chevron { transform: rotate(-90deg); }

/* Category colors */
.gc-0 { background-color: #3b82f6; }
.gc-1 { background-color: #10b981; }
.gc-2 { background-color: #f59e0b; }
.gc-3 { background-color: #8b5cf6; }
.gc-4 { background-color: #ef4444; }
.gc-5 { background-color: #06b6d4; }
.gc-6 { background-color: #ec4899; }
.gc-7 { background-color: #f97316; }

/* ── Status badges ───────────────────────────────────────── */
.dir-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.dir-badge-active { background: #dcfce7; color: #166534; }
.dir-badge-contact { background: #fef3c7; color: #92400e; }
.dir-badge-invited { background: #dbeafe; color: #1d4ed8; }
.dir-badge-none { background: #f1f5f9; color: #64748b; }

/* ── Action buttons ──────────────────────────────────────── */
.dir-row-actions { display: flex; gap: 4px; }
.dir-row-btn { padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all 0.12s; }
.dir-row-btn-edit { background: #f0f7ff; color: #2563eb; border-color: #bfdbfe; }
.dir-row-btn-edit:hover { background: #dbeafe; }
.dir-row-btn-invite { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.dir-row-btn-invite:hover { background: #dcfce7; }
.dir-row-btn-remove { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.dir-row-btn-remove:hover { background: #fee2e2; }

/* ── Company grid ────────────────────────────────────────── */
.dir-company-trade { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 500; background: #f1f5f9; color: #475569; }

/* ── Distribution Groups grid ────────────────────────────── */
.dir-member-avatars { display: flex; }
.dir-member-avatar { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; color: white; margin-left: -4px; border: 2px solid white; }
.dir-member-avatar:first-child { margin-left: 0; }

/* ── Modals ──────────────────────────────────────────────── */
.dir-modal-overlay { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; background: rgba(15,23,42,0.5) !important; z-index: 10000 !important; display: none !important; align-items: center !important; justify-content: center !important; backdrop-filter: blur(2px); }
.dir-modal-overlay.show { display: flex !important; }
.dir-modal { background: white !important; border-radius: 12px !important; box-shadow: 0 20px 60px rgba(0,0,0,0.2) !important; width: 520px; max-height: 85vh !important; display: flex !important; flex-direction: column !important; overflow: hidden !important; }
.dir-modal-wide { width: 640px !important; }
.dir-modal-header { padding: 16px 20px !important; border-bottom: 1px solid #e2e8f0 !important; display: flex !important; align-items: center !important; }
.dir-modal-header h3 { font-size: 15px !important; font-weight: 700 !important; color: #0f172a !important; flex: 1 !important; margin: 0 !important; }
.dir-modal-close { background: none !important; border: none !important; font-size: 18px !important; color: #94a3b8 !important; cursor: pointer !important; padding: 4px !important; }
.dir-modal-close:hover { color: #475569 !important; }
.dir-modal-body { padding: 20px !important; overflow-y: auto !important; }
.dir-modal-footer { padding: 12px 20px !important; border-top: 1px solid #e2e8f0 !important; display: flex !important; justify-content: flex-end !important; gap: 8px !important; }

/* ── Form elements ───────────────────────────────────────── */
.dir-form-row { display: flex !important; gap: 12px !important; margin-bottom: 14px !important; }
.dir-form-group { flex: 1 !important; }
.dir-form-group label { display: block !important; font-size: 11px !important; font-weight: 600 !important; color: #475569 !important; margin-bottom: 4px !important; text-transform: uppercase !important; letter-spacing: 0.3px !important; }
.dir-form-group input, .dir-form-group select, .dir-form-group textarea { width: 100% !important; padding: 8px 10px !important; border: 1px solid #d1d5db !important; border-radius: 6px !important; font-size: 13px !important; color: #1e293b !important; outline: none !important; font-family: inherit !important; box-sizing: border-box !important; }
.dir-form-group input:focus, .dir-form-group select:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.dir-form-divider { border: none; border-top: 1px solid #f1f5f9; margin: 16px 0; }

/* ── Org Directory Modal (multi-select) ──────────────────── */
.dir-org-person-list { max-height: 300px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 8px; }
.dir-org-person-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background 0.1s; }
.dir-org-person-row:hover { background: #f0f7ff; }
.dir-org-person-row:last-child { border-bottom: none; }
.dir-org-person-row input[type="checkbox"] { accent-color: #2563eb; }
.dir-org-person-name { font-size: 13px; font-weight: 500; color: #1e293b; flex: 1; }
.dir-org-person-company { font-size: 11px; color: #64748b; }
.dir-org-person-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; }

/* ── Invite Modal ────────────────────────────────────────── */
.dir-invite-person-info { background: #f0f7ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 12px; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.dir-invite-avatar { width: 40px; height: 40px; border-radius: 50%; background: #f59e0b; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: white; }
.dir-invite-name { font-size: 14px; font-weight: 600; color: #0f172a; }
.dir-invite-email { font-size: 12px; color: #64748b; }
.dir-invite-note { background: #fefce8; border: 1px solid #fde68a; border-radius: 6px; padding: 10px 12px; font-size: 11px; color: #854d0e; margin-top: 12px; line-height: 1.5; }
.dir-invite-note b { color: #92400e; }

/* ── Avatar helper ───────────────────────────────────────── */
.dir-avatar { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; color: white; font-size: 9px; font-weight: 700; margin-right: 8px; vertical-align: middle; }

/* ── Empty state ─────────────────────────────────────────── */
.dir-empty { text-align: center; padding: 60px 20px; color: #94a3b8; }
.dir-empty h3 { font-size: 16px; font-weight: 600; color: #64748b; margin-bottom: 8px; }
.dir-empty p { font-size: 13px; }
