/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
       font-size: 14px; color: #1a1a2e; background: #f0f2f8; min-height: 100vh; display: flex; }

/* ── Sidebar ─────────────────────────────────── */
.sidebar { width: 240px; min-height: 100vh; background: #1a1a2e; color: #c8c8e8;
           display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100vh; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px;
                 font-size: 18px; font-weight: 700; color: #fff;
                 border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand-icon { font-size: 22px; }
.nav-links { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-links li a { display: flex; align-items: center; gap: 10px; padding: 10px 18px;
                  color: #a8a8c8; text-decoration: none; border-radius: 6px; margin: 2px 8px;
                  transition: background 0.15s, color 0.15s; font-size: 14px; }
.nav-links li a:hover, .nav-links li a.active { background: rgba(108,92,231,0.25); color: #fff; }
.nav-links li a.active { color: #a78bfa; }
.nav-section { padding: 12px 18px 4px; font-size: 11px; text-transform: uppercase;
               letter-spacing: 1px; color: #6666aa; }
.sidebar-footer { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #6c5ce7;
          color: #fff; display: flex; align-items: center; justify-content: center;
          font-weight: 700; font-size: 14px; flex-shrink: 0; }
.username { font-weight: 600; color: #fff; font-size: 13px; }
.user-role { font-size: 11px; color: #9999cc; }
.logout-btn { display: block; text-align: center; padding: 8px; border-radius: 6px;
              background: rgba(255,255,255,0.07); color: #c8c8e8; text-decoration: none;
              font-size: 13px; transition: background 0.15s; }
.logout-btn:hover { background: rgba(255,80,80,0.25); color: #ff6b6b; }

/* ── Main Content ────────────────────────────── */
.main-content { margin-left: 240px; flex: 1; min-height: 100vh; }
.content-wrapper { padding: 32px; width: 100%; max-width: 100%; box-sizing: border-box; }

/* ── Page Header ─────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between;
               margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 24px; font-weight: 700; color: #1a1a2e; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-block; font-size: 13px; color: #6c5ce7; text-decoration: none;
             margin-bottom: 6px; }
.back-link:hover { text-decoration: underline; }
.text-muted { color: #666; font-size: 13px; }

/* ── Stats Grid ──────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
              gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 12px; padding: 20px;
             box-shadow: 0 1px 4px rgba(0,0,0,0.07); text-align: center; }
.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 13px; color: #888; margin: 4px 0 10px; }
.stat-link { font-size: 12px; color: #6c5ce7; text-decoration: none; }
.stat-link:hover { text-decoration: underline; }

/* ── Dashboard Grid ──────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; }

/* ── Card ────────────────────────────────────── */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.07);
        overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between;
               padding: 16px 20px; border-bottom: 1px solid #eee; }
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-toolbar { padding: 12px 16px; border-bottom: 1px solid #eee; }
.form-card { padding: 24px; }
.detail-card { }

/* ── Table ───────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 600;
            text-transform: uppercase; letter-spacing: 0.5px; color: #888;
            background: #fafafa; border-bottom: 1px solid #eee; }
.table td { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table a { color: #6c5ce7; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.empty { text-align: center; color: #aaa; padding: 24px !important; }
.actions { display: flex; gap: 6px; white-space: nowrap; align-items: center; }
.row-latest { background: #f9fffe; }

/* ── Detail Grid & List ──────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.detail-section { margin-bottom: 0; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* Used on publisher detail page */
.detail-list-simple { padding: 20px; }
.detail-list-simple dt { font-size: 11px; font-weight: 600; text-transform: uppercase;
                         letter-spacing: 0.5px; color: #888; margin-top: 14px; }
.detail-list-simple dt:first-child { margin-top: 0; }
.detail-list-simple dd { margin: 3px 0 0; color: #1a1a2e; }

/* Used on lead analysis detail page */
.detail-list { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; padding: 16px; }
.detail-list dt { font-size: 12px; font-weight: 600; color: #888; text-transform: uppercase;
                  letter-spacing: 0.5px; align-self: start; padding-top: 2px; }
.detail-list dd { font-size: 14px; color: #1a1a2e; margin: 0; }

.description { padding: 16px 20px; border-top: 1px solid #eee; }
.description h3 { font-size: 13px; font-weight: 600; color: #888; margin-bottom: 8px; }
.description p { line-height: 1.6; color: #444; }

/* ── Forms ───────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #444; margin-bottom: 5px; }
.form-control,
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; color: #1a1a2e; background: #fafafa; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s; }
input[type=checkbox], input[type=radio] { width: auto; }
.form-control:focus, input:focus, select:focus, textarea:focus {
  border-color: #6c5ce7; box-shadow: 0 0 0 3px rgba(108,92,231,0.12); background: #fff; }
.has-error .form-control { border-color: #e74c3c; }
.error-text { color: #e74c3c; font-size: 12px; margin-top: 4px; display: block; }
.field-error { color: #e74c3c; font-size: 12px; margin-top: 4px; display: block; }
.help-text { color: #999; font-size: 12px; margin-top: 3px; display: block; }
.form-actions { display: flex; gap: 10px; padding-top: 16px; margin-top: 8px;
                border-top: 1px solid #eee; flex-wrap: wrap; }
.search-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-input { max-width: 280px; }
.inline-form { display: inline; }
.required { color: #ef4444; }
.text-link { font-size: 12px; color: #6c5ce7; margin-left: 6px; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* Lead analysis form layout */
.lead-analysis-form { display: flex; flex-direction: column; gap: 20px; }
.form-section { margin-bottom: 0; }
.lead-analysis-form .form-grid-2 { padding: 16px; }
.form-full { grid-column: 1 / -1; }
@media (max-width: 768px) { .form-grid-2 { grid-template-columns: 1fr; } }

.radio-group { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 4px; }
.radio-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: #374151; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px 24px; padding-top: 4px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: #374151; }
.pain-list { list-style: disc; padding-left: 18px; margin: 0; }
.pain-list li { font-size: 13px; color: #374151; }

/* ── Buttons ─────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
       text-decoration: none; cursor: pointer; border: none; transition: all 0.15s;
       white-space: nowrap; }
.btn-primary   { background: #6c5ce7; color: #fff; }
.btn-primary:hover { background: #5a4bd1; }
.btn-secondary { background: #f0eeff; color: #6c5ce7; }
.btn-secondary:hover { background: #e2dcff; }
.btn-outline   { background: transparent; color: #555; border: 1px solid #ddd; }
.btn-outline:hover { border-color: #6c5ce7; color: #6c5ce7; }
.btn-danger    { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

/* ── Badges ──────────────────────────────────── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success      { background: #d1fae5; color: #059669; }
.badge-muted        { background: #f3f4f6; color: #6b7280; }
.badge-danger       { background: #fee2e2; color: #dc2626; }
.badge-role         { background: #ede9fe; color: #7c3aed; }
.badge-perm         { background: #e0f2fe; color: #0369a1; font-size: 10px; }
/* Opportunity level badges */
.badge-high         { background: #d1fae5; color: #065f46; }
.badge-medium       { background: #fef3c7; color: #92400e; }
.badge-low          { background: #fee2e2; color: #991b1b; }
.badge-not_suitable { background: #f3f4f6; color: #374151; }

/* ── Alerts ──────────────────────────────────── */
.messages { margin-bottom: 20px; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error, .alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ── Pagination ──────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 12px; padding: 14px 16px;
              border-top: 1px solid #eee; justify-content: center; }
.page-btn { padding: 6px 14px; border-radius: 6px; background: #f0eeff; color: #6c5ce7;
            text-decoration: none; font-size: 13px; font-weight: 600; }
.page-btn:hover { background: #6c5ce7; color: #fff; }
.page-info { color: #888; font-size: 13px; }

/* ── Login Page ──────────────────────────────── */
.login-page { min-height: 100vh; width: 100%; display: flex; align-items: center;
              justify-content: center; background: #1a1a2e; }
.login-card { background: #fff; border-radius: 16px; padding: 40px;
              width: 100%; max-width: 400px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.login-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; color: #1a1a2e; }
.login-subtitle { text-align: center; color: #888; margin-bottom: 28px; font-size: 13px; }
.login-form .btn-block { margin-top: 8px; }
.login-footer {
  text-align: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}
.forgot-password-link {
  color: #6c5ce7;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.forgot-password-link:hover {
  text-decoration: underline;
}
.back-to-login {
  color: #6c5ce7;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.back-to-login:hover {
  text-decoration: underline;
}
.password-rules {
  background: #f8f9fa;
  border: 1px solid #e8e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: #666;
}
.password-rules p {
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}
.password-rules ul {
  list-style: disc;
  padding-left: 18px;
  margin: 0;
}
.password-rules li {
  padding: 2px 0;
}

/* ── Tabs ────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid #e8e8f0; }
.tab { padding: 10px 20px; font-size: 14px; font-weight: 500; color: #666;
       text-decoration: none; border-radius: 6px 6px 0 0;
       border: 1px solid transparent; border-bottom: none;
       margin-bottom: -2px; transition: color 0.15s, background 0.15s;
       display: flex; align-items: center; gap: 6px; }
.tab:hover { color: #6c5ce7; background: #f5f3ff; }
.tab-active { color: #6c5ce7; background: #fff; border-color: #e8e8f0;
              border-bottom-color: #fff; font-weight: 600; }
.tab-badge { background: #6c5ce7; color: #fff; font-size: 11px; font-weight: 700;
             padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center; }

/* ── Activity Timeline ───────────────────────── */
.activity-timeline { padding: 8px 0; }
.activity-item { display: flex; gap: 14px; padding: 14px 20px;
                 border-bottom: 1px solid #f0f0f8; transition: background 0.1s; }
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: #faf9ff; }
.activity-icon { font-size: 20px; flex-shrink: 0; padding-top: 2px; }
.activity-body { flex: 1; min-width: 0; }
.activity-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.activity-badge-created  { background: #d1fae5; color: #065f46; }
.activity-badge-updated  { background: #dbeafe; color: #1e40af; }
.activity-badge-deleted  { background: #fee2e2; color: #991b1b; }
.activity-badge-imported { background: #fef3c7; color: #92400e; }
.activity-action { font-size: 11px; font-weight: 700; text-transform: uppercase;
                   letter-spacing: 0.5px; padding: 2px 8px; border-radius: 4px; }
.activity-publisher { font-weight: 600; color: #1a1a2e; text-decoration: none; font-size: 14px; }
a.activity-publisher:hover { color: #6c5ce7; text-decoration: underline; }
.activity-user { font-size: 13px; color: #555; }
.activity-time { font-size: 12px; color: #999; margin-left: auto; white-space: nowrap; }
.activity-changes { margin-top: 8px; }
.activity-diff-table { width: 100%; border-collapse: collapse; font-size: 12px;
                        background: #fafafa; border-radius: 6px; overflow: hidden;
                        border: 1px solid #ebebf5; }
.activity-diff-table th { background: #f0f0f8; padding: 5px 10px; text-align: left;
                           font-weight: 600; color: #555; text-transform: uppercase; font-size: 11px; }
.activity-diff-table td { padding: 5px 10px; border-top: 1px solid #ebebf5; }
.activity-diff-table td code { background: #eee; padding: 1px 4px; border-radius: 3px; font-size: 11px; }
.diff-old { color: #991b1b; background: #fff5f5; }
.diff-new { color: #065f46; background: #f0fdf4; }

/* ── Role Cards ──────────────────────────────── */
.role-card { margin-bottom: 20px; }
.role-card-header { display: flex; align-items: center; justify-content: space-between;
                    padding: 16px 20px; border-bottom: 1px solid #eee; flex-wrap: wrap; gap: 10px; }
.role-title-group { display: flex; align-items: center; gap: 10px; }
.role-name { font-size: 17px; font-weight: 700; color: #1a1a2e; }
.role-perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
                  gap: 16px; padding: 16px 20px; }
.perm-module { }
.perm-module-title { font-size: 11px; font-weight: 700; text-transform: uppercase;
                     letter-spacing: 0.8px; color: #6c5ce7; margin-bottom: 8px;
                     padding-bottom: 4px; border-bottom: 1px solid #ede9fe; }
.perm-item { font-size: 12px; padding: 4px 0; display: flex; align-items: center; gap: 6px; color: #555; }
.perm-granted { color: #1a1a2e; }
.perm-denied  { color: #bbb; }

/* ── Permission Picker ───────────────────────── */
.perm-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
                    gap: 20px; padding: 20px; }
.perm-picker-module { background: #faf9ff; border: 1px solid #ede9fe; border-radius: 10px; overflow: hidden; }
.perm-picker-module-header { background: #ede9fe; padding: 10px 14px; border-bottom: 1px solid #ddd8f8; }
.perm-module-check-all { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.perm-module-check-all input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: #6c5ce7; }
.perm-picker-items { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.perm-checkbox-label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer;
                        padding: 5px 6px; border-radius: 6px; transition: background 0.1s; }
.perm-checkbox-label:hover { background: #ede9fe; }
.perm-checkbox-label input[type=checkbox] { width: 14px; height: 14px; margin-top: 2px;
                                             flex-shrink: 0; accent-color: #6c5ce7; }
.perm-label-text { font-size: 13px; color: #1a1a2e; line-height: 1.4; }
.perm-codename { font-size: 10px; color: #aaa; font-family: monospace; margin-left: auto; white-space: nowrap; }

/* ── Import Page ─────────────────────────────── */
.import-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.import-upload-card { }
.import-sidebar { }
.drop-zone { border: 2px dashed #d0c8ff; border-radius: 12px; padding: 40px 24px;
             text-align: center; background: #faf9ff;
             transition: border-color 0.2s, background 0.2s; cursor: pointer; }
.drop-zone--hover, .drop-zone:hover { border-color: #6c5ce7; background: #f0eeff; }
.drop-zone--active { border-color: #6c5ce7; background: #f0eeff; }
.drop-zone-icon { font-size: 40px; margin-bottom: 10px; }
.drop-zone-text { font-size: 15px; font-weight: 600; color: #1a1a2e; margin-bottom: 4px; }
.drop-zone-sub  { font-size: 13px; color: #aaa; margin-bottom: 12px; }
.drop-zone-filename { margin-top: 14px; font-size: 13px; color: #6c5ce7; font-weight: 600; min-height: 20px; }
.import-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.import-stat { border-radius: 10px; padding: 14px; text-align: center;
               display: flex; flex-direction: column; gap: 4px; }
.import-stat-ok   { background: #d1fae5; }
.import-stat-skip { background: #fef3c7; }
.import-stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; line-height: 1; }
.import-stat-label { font-size: 12px; color: #666; }
.import-errors { background: #fff8f0; border: 1px solid #ffd6a5; border-radius: 8px;
                 padding: 12px 16px; max-height: 220px; overflow-y: auto; }
.import-errors-title { font-weight: 600; color: #92400e; margin-bottom: 8px; font-size: 13px; }
.import-errors ul { list-style: none; padding: 0; }
.import-errors li { font-size: 12px; color: #7c3a00; padding: 3px 0; border-bottom: 1px solid #ffe4c4; }
.import-errors li:last-child { border-bottom: none; }

/* ── Lead Analysis — Opportunity Banner ──────── */
.opportunity-banner { display: flex; align-items: center; gap: 12px;
                      padding: 14px 20px; border-radius: 10px; margin-bottom: 24px;
                      font-size: 16px; font-weight: 600; }
.opportunity-high        { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.opportunity-medium      { background: #fef3c7; color: #92400e; border-left: 4px solid #f59e0b; }
.opportunity-low         { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.opportunity-not_suitable{ background: #f3f4f6; color: #374151; border-left: 4px solid #9ca3af; }
.opp-label { font-size: 13px; font-weight: 500; opacity: 0.75; }
.opp-value { font-size: 18px; font-weight: 700; }

/* ── Stage Indicator ─────────────────────────── */
.stage-indicator { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.stage-step { display: flex; align-items: center; gap: 8px; padding: 8px 16px;
              border-radius: 20px; font-size: 13px; font-weight: 600;
              border: 2px solid #e0e0f0; color: #aaa; background: #fafafa; }
.stage-active  { border-color: #6c5ce7; color: #6c5ce7; background: #f0eeff; }
.stage-done    { border-color: #10b981; color: #059669; background: #f0fdf4; }
.stage-pending { border-color: #e0e0f0; color: #bbb;    background: #fafafa; }
.stage-divider { color: #ccc; font-size: 18px; }
.stage-num { width: 22px; height: 22px; border-radius: 50%;
             display: flex; align-items: center; justify-content: center;
             font-size: 12px; font-weight: 700; }
.stage-active  .stage-num { background: #6c5ce7; color: #fff; }
.stage-done    .stage-num { background: #10b981; color: #fff; }
.stage-pending .stage-num { background: #ddd;    color: #888; }

/* ── Publisher Search Dropdown ───────────────── */
.search-dropdown { position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
                   background: #fff; border: 1px solid #ddd; border-top: none;
                   border-radius: 0 0 8px 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.1);
                   max-height: 240px; overflow-y: auto; }
.dropdown-item { padding: 10px 14px; cursor: pointer; font-size: 14px; color: #1a1a2e;
                 border-bottom: 1px solid #f0f0f0; transition: background 0.1s; }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #f0eeff; color: #6c5ce7; }

/* ── Selected Publisher Badge ────────────────── */
.selected-badge { display: flex; align-items: center; gap: 8px; padding: 9px 12px;
                  background: #f0eeff; border: 1px solid #c4b5fd; border-radius: 8px;
                  font-size: 14px; color: #5b21b6; font-weight: 500; }
.badge-clear { border: none; background: none; cursor: pointer;
               color: #7c3aed; font-size: 14px; padding: 0 2px; line-height: 1; }
.badge-clear:hover { color: #ef4444; }

/* ── Stage 2 Selection Summary ───────────────── */
.selection-summary { display: flex; align-items: center; padding: 0; margin-bottom: 20px; overflow: hidden; }
.summary-item { display: flex; flex-direction: column; gap: 2px; padding: 14px 20px; flex: 1; }
.summary-label { font-size: 11px; font-weight: 600; text-transform: uppercase;
                 letter-spacing: 0.5px; color: #888; }
.summary-value { font-size: 15px; font-weight: 700; color: #1a1a2e; }
.summary-meta  { font-size: 11px; color: #aaa; }
.summary-divider { width: 1px; background: #eee; align-self: stretch; }
.summary-change { margin: 12px 16px 12px auto; white-space: nowrap; flex-shrink: 0; }

/* ── Version Badges ──────────────────────────── */
.version-badge { display: inline-flex; align-items: center; padding: 3px 10px;
                 border-radius: 12px; font-size: 12px; font-weight: 700;
                 vertical-align: middle; margin-left: 8px; }
.version-badge-sm { display: inline-block; padding: 2px 7px; border-radius: 10px;
                    font-size: 11px; font-weight: 700; }
.version-latest { background: #d1fae5; color: #065f46; }
.version-old    { background: #fef3c7; color: #92400e; }

/* ── Version Timeline ────────────────────────── */
.version-timeline { display: flex; flex-direction: column; }
.version-item { display: flex; gap: 14px; padding: 14px 16px;
                border-bottom: 1px solid #f0f0f8; transition: background 0.1s; }
.version-item:last-child { border-bottom: none; }
.version-item:hover { background: #faf9ff; }
.version-item-current { background: #f0eeff !important; }
.version-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.dot-latest { background: #10b981; }
.dot-old    { background: #d1d5db; }
.dot-green  { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
              background: #10b981; margin-right: 4px; vertical-align: middle; }
.dot-grey   { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
              background: #d1d5db; margin-right: 4px; vertical-align: middle; }
.version-body { flex: 1; min-width: 0; }
.version-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.version-analyst { font-size: 13px; color: #374151; font-weight: 500; }
.version-date { font-size: 12px; color: #9ca3af; margin-left: auto; }
.version-actions { margin-top: 6px; }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; min-height: auto; position: relative; height: auto; }
  .main-content { margin-left: 0; }
  body { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .import-layout { grid-template-columns: 1fr; }
  .selection-summary { flex-direction: column; align-items: stretch; }
  .summary-divider { width: auto; height: 1px; }
}

/* ── Analysis Module Cards ───────────────────── */
.analysis-modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.25rem; }
.analysis-module-card { display: flex; align-items: center; gap: 1rem; padding: 1.5rem;
  background: #fff; border-radius: 10px; border: 1px solid #e8e8f0;
  text-decoration: none; color: inherit; transition: box-shadow 0.2s, border-color 0.2s; }
a.analysis-module-card:hover { box-shadow: 0 4px 16px rgba(108,92,231,0.12); border-color: #a78bfa; }
.analysis-module-card .module-icon { font-size: 2.5rem; flex-shrink: 0; }
.analysis-module-card .module-body h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.35rem; color: #1a1a2e; }
.analysis-module-card .module-body p { font-size: 0.82rem; color: #666; line-height: 1.45; margin: 0; }
.analysis-module-card .module-body .module-meta { margin-top: 0.6rem; }
.analysis-module-card .module-arrow { font-size: 1.4rem; color: #a78bfa; margin-left: auto; flex-shrink: 0; }
.analysis-module-coming-soon { border-style: dashed; cursor: default; }

/* ── Lead Status Badges ──────────────────────── */
.badge-status-new { background: #ebf5ff; color: #2980b9; }
.badge-status-contacted { background: #f0ebff; color: #7c3aed; }
.badge-status-qualified { background: #fff8eb; color: #d97706; }
.badge-status-proposal { background: #e8faf5; color: #0d9488; }
.badge-status-negotiation { background: #eef0ff; color: #4f46e5; }
.badge-status-won { background: #ecfdf5; color: #059669; }
.badge-status-lost { background: #fef2f2; color: #dc2626; }

/* ── Task Status Badges ──────────────────────── */
.badge-status-todo { background: #f3f4f6; color: #6b7280; }
.badge-status-in_progress { background: #ebf5ff; color: #2563eb; }
.badge-status-in_review { background: #fff8eb; color: #d97706; }
.badge-status-done { background: #ecfdf5; color: #059669; }
.badge-status-cancelled { background: #fef2f2; color: #dc2626; }

/* ── Social Calendar Status Badges ───────────── */
.badge-social-draft { background: #f3f4f6; color: #6b7280; }
.badge-social-level1_approved { background: #fff8eb; color: #d97706; }
.badge-social-level2_approved { background: #ebf5ff; color: #2563eb; }
.badge-social-scheduled { background: #f0ebff; color: #7c3aed; }
.badge-social-posted { background: #ecfdf5; color: #059669; }
.badge-social-rejected { background: #fef2f2; color: #dc2626; }
.badge-outline { background: transparent; border: 1px solid #d1d5db; color: #374151; }

/* ── Knowledge Base Badges ───────────────────── */
.badge-kb-public { background: #ecfdf5; color: #059669; }
.badge-kb-internal { background: #fff8eb; color: #d97706; }
.badge-kb-status-draft { background: #f3f4f6; color: #6b7280; }
.badge-kb-status-published { background: #ecfdf5; color: #059669; }

/* ── View Toggle ─────────────────────────────── */
.view-toggle { display: inline-flex; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; }
.view-toggle-btn { display: flex; align-items: center; gap: 5px; padding: 7px 14px;
                   font-size: 13px; font-weight: 600; color: #666; text-decoration: none;
                   background: #fff; border-right: 1px solid #ddd; transition: all 0.15s; }
.view-toggle-btn:last-child { border-right: none; }
.view-toggle-btn:hover { background: #f5f3ff; color: #6c5ce7; }
.view-toggle-btn.active { background: #6c5ce7; color: #fff; }

/* ── Task Calendar ───────────────────────────── */
.task-calendar { padding: 0; min-height: 500px; }
.cal-grid { display: flex; flex-direction: column; }
.cal-header-row { display: grid; grid-template-columns: repeat(7, 1fr);
                  border-bottom: 1px solid #eee; background: #fafafa; }
.cal-header-cell { padding: 10px 8px; text-align: center; font-size: 12px;
                   font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #888; }
.cal-body-row { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day-cell { min-height: 110px; padding: 6px 8px; border-bottom: 1px solid #f0f0f0;
                border-right: 1px solid #f0f0f0; position: relative;
                transition: background 0.1s; cursor: default; }
.cal-day-cell:nth-child(7n) { border-right: none; }
.cal-body-row:last-child .cal-day-cell { border-bottom: none; }
.cal-day-empty { background: #f9f9fc; }
.cal-day-today { background: #f5f3ff; }
.cal-day-has-events { cursor: pointer; }
.cal-day-has-events:hover { background: #f0eeff; }
.cal-day-num { font-size: 13px; font-weight: 600; color: #999; margin-bottom: 4px; }
.cal-today-num { color: #fff; background: #6c5ce7; width: 24px; height: 24px;
                 border-radius: 50%; display: flex; align-items: center; justify-content: center;
                 font-size: 12px; }
.cal-day-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event-chip { display: flex; align-items: center; gap: 4px; padding: 2px 5px;
                  background: #f8f7ff; border-radius: 3px; font-size: 11px;
                  overflow: hidden; white-space: nowrap; }
.cal-event-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cal-dot-estimated { background: #6c5ce7; }
.cal-dot-actual { background: #10b981; }
.cal-event-label { overflow: hidden; text-overflow: ellipsis; color: #374151; font-weight: 500; }
.cal-event-more { font-size: 10px; color: #6c5ce7; font-weight: 600; padding: 1px 5px; }

/* Calendar legend */
.cal-legend { display: flex; gap: 16px; align-items: center; }
.cal-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px;
                   font-weight: 600; color: #666; }
.cal-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Calendar navigation */
.cal-nav { display: flex; align-items: center; gap: 6px; }

/* Calendar tooltip */
.cal-tooltip { position: absolute; z-index: 999; background: #fff; border: 1px solid #ddd;
               border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,0.15);
               max-height: 320px; overflow-y: auto; }
.cal-tooltip-inner { padding: 6px; }
.cal-tooltip-event { display: block; padding: 10px 12px; border-radius: 8px;
                     text-decoration: none; color: inherit; transition: background 0.1s;
                     border-left: 4px solid transparent; margin-bottom: 4px; }
.cal-tooltip-event:last-child { margin-bottom: 0; }
.cal-tooltip-event:hover { background: #f5f3ff; }
.cal-evt-estimated { border-left-color: #6c5ce7; background: #faf9ff; }
.cal-evt-actual { border-left-color: #10b981; background: #f0fdf4; }
.cal-tooltip-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.cal-tooltip-type { font-size: 10px; font-weight: 700; text-transform: uppercase;
                    letter-spacing: 0.5px; padding: 2px 6px; border-radius: 3px; }
.cal-evt-estimated .cal-tooltip-type { background: #ede9fe; color: #6c5ce7; }
.cal-evt-actual .cal-tooltip-type { background: #d1fae5; color: #059669; }
.cal-tooltip-title { font-size: 13px; font-weight: 700; color: #1a1a2e; margin-bottom: 2px; }
.cal-tooltip-meta { font-size: 11px; color: #888; }

@media (max-width: 768px) {
  .cal-day-cell { min-height: 70px; padding: 4px; }
  .cal-event-chip { display: none; }
  .cal-day-has-events .cal-day-num::after { content: ''; display: inline-block;
    width: 6px; height: 6px; border-radius: 50%; background: #6c5ce7; margin-left: 4px; vertical-align: middle; }
  .view-toggle-btn span:first-child { display: none; }
}

/* ── Lead Priority Badges ────────────────────── */
.badge-priority-low { background: #f3f4f6; color: #6b7280; }
.badge-priority-medium { background: #fff8eb; color: #d97706; }
.badge-priority-high { background: #fef2f2; color: #dc2626; }
.badge-priority-critical { background: #450a0a; color: #fca5a5; }

/* ── Pipeline Bars ───────────────────────────── */
.pipeline-bar { height: 8px; background: #f0f2f8; border-radius: 4px; overflow: hidden; }
.pipeline-bar-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.pipeline-fill-new { background: #2980b9; }
.pipeline-fill-contacted { background: #7c3aed; }
.pipeline-fill-qualified { background: #d97706; }
.pipeline-fill-proposal { background: #0d9488; }
.pipeline-fill-negotiation { background: #4f46e5; }
.pipeline-fill-won { background: #059669; }
.pipeline-fill-lost { background: #dc2626; }

/* ── Form Fieldsets ──────────────────────────── */
.lead-form { padding: 1.5rem; }
.form-fieldset { border: 1px solid #e8e8f0; border-radius: 8px; padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.form-fieldset legend { font-weight: 700; font-size: 0.95rem; color: #1a1a2e; padding: 0 0.5rem; }
.form-fieldset .form-grid-2 { padding: 0; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1.25rem; }
.lead-form > .form-actions { padding: 1.25rem 0 0; margin-top: 0.5rem; border-top: 1px solid #e8e8f0; }
.form-fieldset .form-group { margin-bottom: 0.5rem; }
.form-fieldset .form-group:last-child { margin-bottom: 0; }
.form-fieldset > .form-grid-2 + .form-group { margin-top: 0.75rem; }

/* ── Interaction Timeline ────────────────────── */
.interaction-timeline { padding: 0; }

/* ── Lead Detail Layout ──────────────────────── */
.lead-detail-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.lead-detail-info { grid-column: 1 / -1; }
.lead-detail-info .detail-meta { margin: 0; padding: 1rem 16px; border-top: 1px solid #eee; font-size: 0.82rem; color: #888; }
@media (max-width: 900px) { .lead-detail-layout { grid-template-columns: 1fr; } }
.interaction-item { padding: 1rem 1.5rem; border-bottom: 1px solid #f0f2f8; }
.interaction-item:last-child { border-bottom: none; }
.interaction-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.35rem; }
.interaction-type-badge { font-size: 0.82rem; font-weight: 600; }
.interaction-meta { font-size: 0.78rem; color: #888; }
.interaction-subject { font-size: 0.92rem; margin-bottom: 0.25rem; }
.interaction-body { font-size: 0.85rem; color: #555; line-height: 1.5; }

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

/* ── Import Column Mapping Grid ──────────────── */
.import-mapping-grid {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  gap: 0.75rem 1rem;
  align-items: center;
}
.import-mapping-header {
  font-weight: 600; font-size: 0.82rem; color: #888; text-transform: uppercase;
}
.import-mapping-arrow {
  text-align: center; color: #aaa; font-size: 1.1rem;
}
.import-mapping-label {
  padding: 0.5rem 0.75rem; background: #f8f9fa; border-radius: 6px;
  font-weight: 500; word-break: break-word; min-width: 0;
}
.import-mapping-select {
  min-width: 0;
}
.import-mapping-select select {
  width: 100%;
}
.import-footer {
  padding: 1.5rem; display: flex; justify-content: space-between;
  align-items: center; gap: 1rem; flex-wrap: wrap;
}
.import-footer-hint {
  font-size: 0.9rem; color: #666; flex: 1; min-width: 200px;
}
.import-footer-actions {
  display: flex; gap: 0.5rem; flex-shrink: 0;
}

/* Small laptops: stack label above select */
@media (max-width: 1100px) {
  .import-mapping-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .import-mapping-header:nth-child(2),
  .import-mapping-header:nth-child(3) { display: none; }
  .import-mapping-header:first-child {
    margin-bottom: 0.5rem;
  }
  .import-mapping-arrow { display: none; }
  .import-mapping-label {
    margin-top: 0.75rem;
    border-radius: 6px 6px 0 0;
    font-size: 0.82rem;
    color: #555;
    padding: 0.4rem 0.75rem;
  }
  .import-mapping-select {
    margin-bottom: 0;
  }
  .import-mapping-select select {
    border-radius: 0 0 6px 6px;
    border-top: none;
  }
}

/* ── Searchable Select ───────────────────────────── */
.ss-wrapper { position: relative; }
.ss-display {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 9px 12px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; color: #1a1a2e; background: #fafafa; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ss-display:focus, .ss-open .ss-display {
  border-color: #6c5ce7; box-shadow: 0 0 0 3px rgba(108,92,231,0.12); background: #fff; outline: none;
}
.ss-display-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-placeholder { color: #999; }
.ss-arrow { font-size: 10px; color: #999; margin-left: 8px; transition: transform 0.15s; }
.ss-open .ss-arrow { transform: rotate(180deg); }

.ss-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  margin-top: 4px; background: #fff; border: 1px solid #ddd; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); overflow: hidden;
}
.ss-open .ss-dropdown { display: block; }

.ss-search {
  width: 100%; padding: 9px 12px; border: none; border-bottom: 1px solid #eee;
  font-size: 13px; outline: none; background: #fafafa;
}
.ss-search:focus { background: #fff; }

.ss-list {
  list-style: none; max-height: 220px; overflow-y: auto; padding: 4px 0; margin: 0;
}
.ss-option {
  padding: 8px 12px; font-size: 13px; cursor: pointer; transition: background 0.1s;
}
.ss-option:hover { background: #f0eeff; }
.ss-option.ss-selected { background: #ede9fe; color: #6c5ce7; font-weight: 600; }

/* ── Galley File Card ────────────────────────────── */
.file-card {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
  background: #f8f9fa; border: 1px solid #e5e7eb; border-radius: 8px; margin-top: 0.5rem;
}
.file-card-icon { font-size: 1.5rem; flex-shrink: 0; }
.file-card-info { flex: 1; min-width: 0; }
.file-card-name {
  font-size: 0.85rem; font-weight: 500; color: #1a1a2e;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-card-meta { font-size: 0.75rem; color: #888; margin-top: 2px; }
.file-card-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* ── Impersonation Banner ────────────────────── */
.impersonation-banner {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  color: #78350f;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 14px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.impersonation-banner strong {
  color: #92400e;
}
.btn-impersonate-stop {
  background: #78350f;
  color: #fef3c7;
  border: none;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-impersonate-stop:hover {
  background: #451a03;
  color: #fff;
}
.btn-impersonate {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}
.btn-impersonate:hover {
  background: #fbbf24;
  color: #78350f;
}
.btn-impersonate-lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid #f59e0b;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #78350f;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
  transition: all 0.15s;
}
.btn-impersonate-lg:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #451a03;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
  transform: translateY(-1px);
}
