/* ============================================================
   Ather — App Shell Design System
   Option C: Warm Arabic Premium
   Font: Cairo (Arabic + Latin, Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

/* ============================================================
   Hard reset: prevent any theme dark-mode styles from bleeding
   into the app shell. This block must stay at the top.
   ============================================================ */
body.icrm-app-shell-body {
  background: #faf7f2 !important;
  color: #1e1218 !important;
  font-family: 'Cairo', 'Tajawal', system-ui, sans-serif !important;
  line-height: 1.85 !important;
}
html:has(body.icrm-app-shell-body) {
  background: #faf7f2;
}

:root {
  /* --- Palette --- */
  --icrm-bg:              #faf7f2;
  --icrm-surface:         #ffffff;
  --icrm-surface-alt:     #fdf6ee;
  --icrm-surface-raised:  #ffffff;
  --icrm-border:          #e2d5c3;
  --icrm-border-soft:     #ede5d8;

  /* --- Text --- */
  --icrm-text:            #1e1218;
  --icrm-text-soft:       #6b5464;
  --icrm-text-muted:      #9e8491;

  /* --- Accent: deep violet --- */
  --icrm-accent:          #7c3aed;
  --icrm-accent-hover:    #6d28d9;
  --icrm-accent-soft:     #f0e9ff;
  --icrm-accent-border:   #d8b4fe;

  /* --- Gold: premium highlight --- */
  --icrm-gold:            #b7882c;
  --icrm-gold-hover:      #9e721f;
  --icrm-gold-soft:       #fdf3de;
  --icrm-gold-border:     #f0cc80;

  /* --- Semantic --- */
  --icrm-danger:          #b91c1c;
  --icrm-danger-soft:     #fef2f2;
  --icrm-danger-border:   #fecaca;
  --icrm-warning:         #92400e;
  --icrm-warning-soft:    #fffbeb;
  --icrm-warning-border:  #fde68a;
  --icrm-success:         #14532d;
  --icrm-success-soft:    #f0fdf4;
  --icrm-success-border:  #bbf7d0;
  --icrm-info:            #1e3a5f;
  --icrm-info-soft:       #eff6ff;
  --icrm-info-border:     #bfdbfe;

  /* --- Shape --- */
  --icrm-radius-sm:       10px;
  --icrm-radius:          16px;
  --icrm-radius-lg:       22px;
  --icrm-radius-xl:       28px;
  --icrm-radius-pill:     999px;

  /* --- Shadow --- */
  --icrm-shadow-xs:       0 1px 3px rgba(30, 18, 24, 0.06);
  --icrm-shadow:          0 4px 16px rgba(30, 18, 24, 0.08);
  --icrm-shadow-lg:       0 8px 32px rgba(30, 18, 24, 0.11);
  --icrm-shadow-accent:   0 4px 20px rgba(124, 58, 237, 0.18);

  /* --- Layout --- */
  --icrm-max:             1440px;
  --icrm-sidebar-w:       280px;

  /* --- Transition --- */
  --icrm-ease:            cubic-bezier(0.4, 0, 0.2, 1);
  --icrm-duration:        160ms;
}

/* ============================================================
   Reset + Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--icrm-bg);
  color: var(--icrm-text);
  font-family: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ============================================================
   App Shell Layout
   ============================================================ */
.icrm-app-shell {
  min-height: 100vh;
  max-width: var(--icrm-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--icrm-sidebar-w) 1fr;
  gap: 24px;
  padding: 24px;
}

/* ============================================================
   Sidebar
   ============================================================ */
.icrm-sidebar {
  background: var(--icrm-surface);
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius-xl);
  box-shadow: var(--icrm-shadow);
  padding: 20px 16px;
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

/* Subtle gradient wash on sidebar */
.icrm-sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(124, 58, 237, 0.04) 0%, transparent 60%);
  pointer-events: none;
}

.icrm-brand-block {
  display: grid;
  gap: 6px;
}

.icrm-brand-block img {
  height: 112px !important;
  width: auto !important;
  max-width: 100%;
  display: block;
}

.icrm-form-banner {
  display: none;
  font-size: 15px !important;
  font-weight: 500;
  line-height: 1.5;
  padding: 14px 18px !important;
  border-radius: 10px;
  margin-bottom: 16px;
}
.icrm-form-banner:not(:empty) {
  display: block;
}

.icrm-brand-note {
  margin: 0;
  color: var(--icrm-text-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* Nav */
.icrm-nav-list { display: grid; gap: 4px; }

.icrm-nav-link,
.icrm-mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--icrm-radius);
  padding: 9px 12px;
  color: var(--icrm-text-soft);
  font-weight: 500;
  font-size: 13.5px;
  transition: background var(--icrm-duration) var(--icrm-ease),
              color var(--icrm-duration) var(--icrm-ease);
}

.icrm-nav-link:hover {
  background: var(--icrm-surface-alt);
  color: var(--icrm-text);
}

.icrm-nav-link.is-active,
.icrm-mobile-nav-link.is-active {
  background: var(--icrm-accent-soft);
  color: var(--icrm-accent);
  font-weight: 700;
}

.icrm-nav-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--icrm-radius-sm);
  background: var(--icrm-surface-alt);
  font-size: 14px;
  flex-shrink: 0;
  transition: background var(--icrm-duration) var(--icrm-ease);
}

.icrm-nav-link.is-active .icrm-nav-icon {
  background: var(--icrm-accent-soft);
}

/* Sidebar footer / upgrade nudge */
.icrm-sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--icrm-border-soft);
}
.icrm-sidebar-legal {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 12px 12px;
  font-size: 11px;
}
.icrm-sidebar-legal a {
  color: var(--icrm-text-muted, #9ca3af);
  text-decoration: none;
  transition: color 0.15s;
}
.icrm-sidebar-legal a:hover {
  color: var(--icrm-accent, #7c3aed);
}
.icrm-sidebar-legal span {
  color: var(--icrm-border-soft, #e5e7eb);
  font-size: 10px;
}

/* ============================================================
   Main Column
   ============================================================ */
.icrm-main-column {
  min-width: 0;
  padding-bottom: 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   Topbar
   ============================================================ */
.icrm-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 247, 242, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius-lg);
  box-shadow: var(--icrm-shadow-xs);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 18px 22px;
}

.icrm-page-eyebrow {
  margin: 0 0 4px;
  color: var(--icrm-gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.icrm-page-title {
  margin: 0;
  font-size: clamp(22px, 3.5vw, 34px);
  font-weight: 900;
  letter-spacing: -0.3px;
  line-height: 1.2;
  color: var(--icrm-text);
}

.icrm-page-subtitle {
  margin: 6px 0 0;
  color: var(--icrm-text-soft);
  font-size: 13px;
  line-height: 1.7;
  max-width: 55ch;
}

.icrm-topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

/* Search input in topbar */
.icrm-search-wrap {
  position: relative;
}
.icrm-search-input {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius);
  background: var(--icrm-surface);
  color: var(--icrm-text);
  font-family: inherit;
  font-size: 14px;
  width: 200px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  direction: rtl;
}
.icrm-search-input:focus {
  border-color: var(--icrm-accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.icrm-search-input::placeholder { color: var(--icrm-text-muted); }

/* Alert section divider */
.icrm-alert-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 6px;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
  color: #b45309;
  border-bottom: 2px solid #fde68a;
}
.icrm-alert-section-head .icrm-alert-count {
  background: #fde68a;
  color: #92400e;
  border-radius: 20px;
  padding: 1px 10px;
  font-size: 12px;
  font-weight: 800;
}
.icrm-rest-section-head {
  display: flex;
  align-items: center;
  padding: 14px 0 6px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--icrm-text-muted);
  letter-spacing: 0.05em;
  border-top: 1px dashed var(--icrm-border-soft);
}

/* Hide search-no-results message */
.icrm-search-empty { display: none; padding: 16px; color: var(--icrm-text-muted); font-size: 14px; text-align: center; }
.icrm-search-empty.is-visible { display: block; }

/* ============================================================
   Buttons
   ============================================================ */
.icrm-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: var(--icrm-accent);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--icrm-radius);
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  transition: background var(--icrm-duration) var(--icrm-ease),
              box-shadow var(--icrm-duration) var(--icrm-ease),
              transform var(--icrm-duration) var(--icrm-ease);
  white-space: nowrap;
}

.icrm-action-button:hover {
  background: var(--icrm-accent-hover);
  box-shadow: var(--icrm-shadow-accent);
  transform: translateY(-1px);
}

.icrm-action-button:active {
  transform: translateY(0);
  box-shadow: none;
}

.icrm-action-button:focus-visible {
  outline: 2px solid var(--icrm-accent);
  outline-offset: 3px;
}

.icrm-action-button--ghost {
  background: transparent;
  color: var(--icrm-accent);
  border: 1px solid var(--icrm-accent-border);
  box-shadow: none;
}

.icrm-action-button--ghost:hover {
  background: var(--icrm-accent-soft);
  box-shadow: none;
  transform: none;
}

.icrm-action-button--gold {
  background: var(--icrm-gold);
  color: #fff;
}

.icrm-action-button--gold:hover {
  background: var(--icrm-gold-hover);
  box-shadow: 0 4px 16px rgba(183, 136, 44, 0.28);
}

.icrm-action-button--danger {
  background: transparent;
  color: var(--icrm-danger);
  border: 1px solid var(--icrm-danger-border);
  box-shadow: none;
}

.icrm-action-button--danger:hover {
  background: var(--icrm-danger-soft);
  box-shadow: none;
  transform: none;
}

.icrm-action-button.is-disabled,
.icrm-action-button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

/* Export CSV button — uses ghost style, add download icon via content */
.icrm-action-button--export::before {
  content: '⬇';
  font-size: 12px;
  margin-left: 4px;
}

/* ============================================================
   WordPress admin bar — hide on app shell pages
   ============================================================ */
body.icrm-app-shell-body #wpadminbar {
  display: none !important;
}

body.icrm-app-shell-body {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* ============================================================
   Surface components
   ============================================================ */
.icrm-panel,
.icrm-record-card,
.icrm-metric-card,
.icrm-board-column,
.icrm-sheet-card,
.icrm-empty-state {
  background: var(--icrm-surface);
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius-lg);
  box-shadow: var(--icrm-shadow);
}

.icrm-metric-card,
.icrm-panel,
.icrm-record-card,
.icrm-empty-state,
.icrm-board-column { padding: 20px; }

/* ============================================================
   Content layout
   ============================================================ */
.icrm-content { display: grid; gap: 20px; }
.icrm-section, .icrm-grid { display: grid; gap: 16px; }
.icrm-grid--dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.icrm-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.icrm-section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--icrm-text);
}

.icrm-section-head a {
  color: var(--icrm-accent);
  font-size: 13px;
  font-weight: 600;
  transition: opacity var(--icrm-duration) var(--icrm-ease);
}

.icrm-section-head a:hover { opacity: 0.75; }

/* Override any theme heading color bleed */
.icrm-app-shell h1,
.icrm-app-shell h2,
.icrm-app-shell h3,
.icrm-app-shell h4 {
  color: var(--icrm-text);
  font-weight: 700;
}

.icrm-muted-note {
  color: var(--icrm-text-muted);
  font-size: 13px;
}

/* ============================================================
   Foundation banner (de-emphasized)
   ============================================================ */
.icrm-foundation-banner {
  background: var(--icrm-gold-soft);
  border: 1px solid var(--icrm-gold-border);
  border-radius: var(--icrm-radius);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--icrm-gold);
  font-size: 13px;
  box-shadow: none;
}

.icrm-foundation-banner strong {
  color: var(--icrm-gold);
  white-space: nowrap;
}

/* ============================================================
   Metric cards
   ============================================================ */
.icrm-metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.icrm-metric-grid--urgent { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.icrm-metric-label {
  display: block;
  color: var(--icrm-text-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.icrm-metric-value {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.5px;
  color: var(--icrm-text);
}

/* Tone modifiers */
.tone-danger {
  background: var(--icrm-danger-soft);
  border-color: var(--icrm-danger-border);
}
.tone-danger .icrm-metric-label { color: var(--icrm-danger); }
.tone-danger .icrm-metric-value { color: var(--icrm-danger); }

.tone-warning {
  background: var(--icrm-warning-soft);
  border-color: var(--icrm-warning-border);
}
.tone-warning .icrm-metric-label { color: var(--icrm-warning); }
.tone-warning .icrm-metric-value { color: var(--icrm-warning); }

.tone-success {
  background: var(--icrm-success-soft);
  border-color: var(--icrm-success-border);
}
.tone-success .icrm-metric-label { color: var(--icrm-success); }
.tone-success .icrm-metric-value { color: var(--icrm-success); }

/* ============================================================
   List + Record cards
   ============================================================ */
.icrm-list-stack { display: grid; gap: 0; }

.icrm-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--icrm-border-soft);
}

.icrm-list-item:last-child { border-bottom: none; padding-bottom: 0; }
.icrm-list-item:first-child { padding-top: 0; }

.icrm-list-item strong { display: block; margin: 0 0 2px; font-size: 14px; font-weight: 700; }
.icrm-list-item span  { color: var(--icrm-text-soft); font-size: 13px; margin: 0; }

.icrm-record-card { display: grid; gap: 14px; }
.icrm-record-card h2 { margin: 0 0 3px; font-size: 16px; font-weight: 800; }
.icrm-record-card p  { margin: 0; color: var(--icrm-text-soft); font-size: 13px; }

.icrm-record-main,
.icrm-record-meta,
.icrm-record-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icrm-record-meta,
.icrm-record-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.icrm-record-meta { color: var(--icrm-text-soft); font-size: 13px; }

.icrm-record-actions button:not(.icrm-action-button),
.icrm-record-actions a:not(.icrm-action-button) {
  border: 1px solid var(--icrm-border);
  background: var(--icrm-surface);
  color: var(--icrm-text);
  border-radius: var(--icrm-radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--icrm-duration) var(--icrm-ease);
}

.icrm-record-actions button:not(.icrm-action-button):hover,
.icrm-record-actions a:not(.icrm-action-button):hover {
  background: var(--icrm-surface-alt);
}

/* ============================================================
   Status chips — per-status color identity
   ============================================================ */
.icrm-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--icrm-radius-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
  background: #eff1f7;
  color: #4a5878;
}

/* Deal statuses */
.icrm-status-chip[data-status="new_inquiry"]         { background: #e8f4fd; color: #1565c0; border-color: #bddff7; }
.icrm-status-chip[data-status="negotiation"]         { background: #fff8e1; color: #e65100; border-color: #ffcc80; }
.icrm-status-chip[data-status="agreed"]              { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.icrm-status-chip[data-status="awaiting_execution"]  { background: #f3e5f5; color: #6a1b9a; border-color: #ce93d8; }
.icrm-status-chip[data-status="posted"]              { background: #e0f2f1; color: #00695c; border-color: #80cbc4; }
.icrm-status-chip[data-status="completed"]           { background: #e8f5e9; color: #1b5e20; border-color: #81c784; }
.icrm-status-chip[data-status="cancelled"]           { background: #fce4ec; color: #880e4f; border-color: #f48fb1; }

/* Deliverable + Payment statuses */
.icrm-status-chip[data-status="pending"]             { background: #fff8e1; color: #e65100; border-color: #ffcc80; }
.icrm-status-chip[data-status="in_progress"]         { background: #e3f2fd; color: #0277bd; border-color: #90caf9; }
.icrm-status-chip[data-status="delivered"]           { background: #e8eaf6; color: #283593; border-color: #9fa8da; }
.icrm-status-chip[data-status="unpaid"]              { background: #fce4ec; color: #c62828; border-color: #ef9a9a; }
.icrm-status-chip[data-status="partially_paid"]      { background: #fff8e1; color: #e65100; border-color: #ffcc80; }
.icrm-status-chip[data-status="paid"]                { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.icrm-status-chip[data-status="overdue"]             { background: #ffebee; color: #b71c1c; border-color: #ef9a9a; }

/* Inline flag (urgency) */
.icrm-inline-flag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--icrm-radius-pill);
  background: var(--icrm-warning-soft);
  color: var(--icrm-warning);
  border: 1px solid var(--icrm-warning-border);
  font-size: 12px;
  font-weight: 700;
}

/* ============================================================
   Filter chips
   ============================================================ */
.icrm-filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.icrm-filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--icrm-radius-pill);
  border: 1px solid var(--icrm-border);
  background: var(--icrm-surface);
  color: var(--icrm-text-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--icrm-duration) var(--icrm-ease),
              color var(--icrm-duration) var(--icrm-ease),
              background var(--icrm-duration) var(--icrm-ease);
}

.icrm-filter-chip:hover,
.icrm-filter-chip.is-active {
  border-color: var(--icrm-accent-border);
  color: var(--icrm-accent);
  background: var(--icrm-accent-soft);
}

/* ============================================================
   View toggle
   ============================================================ */
.icrm-view-toggle {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius);
  background: var(--icrm-surface);
  gap: 2px;
}

.icrm-view-toggle button {
  border: none;
  background: transparent;
  color: var(--icrm-text-soft);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--icrm-duration) var(--icrm-ease),
              color var(--icrm-duration) var(--icrm-ease);
}

.icrm-view-toggle button:hover { color: var(--icrm-text); }

.icrm-view-toggle .is-active {
  background: var(--icrm-accent);
  color: #fff;
}

/* ============================================================
   Deals toolbar
   ============================================================ */
.icrm-deals-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================
   Pipeline Board — Strip + Detail Panel
   ============================================================ */

/* Pipeline strip: all stages always visible */
.icrm-pipeline-strip {
  display: flex;
  background: var(--icrm-surface);
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius);
  overflow: hidden;
  box-shadow: var(--icrm-shadow-xs);
  margin-bottom: 10px;
}

.icrm-stage-pill {
  flex: 1;
  padding: 14px 10px 12px;
  cursor: pointer;
  border-right: 1px solid var(--icrm-border-soft);
  transition: background var(--icrm-duration) var(--icrm-ease);
  position: relative;
  text-align: center;
  min-width: 0;
}
.icrm-stage-pill:first-child { border-right: none; }
.icrm-stage-pill:hover { background: var(--icrm-surface-alt); }
.icrm-stage-pill.is-active { background: var(--icrm-accent-soft); }
.icrm-stage-pill.is-active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--icrm-stage-color, var(--icrm-accent));
}

.icrm-stage-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--icrm-stage-color, var(--icrm-accent));
  vertical-align: middle;
  margin-left: 5px;
  flex-shrink: 0;
}

.icrm-stage-name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--icrm-text-soft);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.icrm-stage-pill.is-active .icrm-stage-name { color: var(--icrm-text); }

.icrm-stage-count {
  display: block;
  font-size: 26px;
  font-weight: 900;
  color: var(--icrm-text);
  line-height: 1;
  margin-bottom: 3px;
}

.icrm-stage-value {
  display: block;
  font-size: 12px;
  color: var(--icrm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icrm-stage-pill.is-active .icrm-stage-value {
  color: var(--icrm-stage-color, var(--icrm-accent));
  font-weight: 700;
}

/* Proportional funnel bar */
.icrm-funnel-bar-wrap {
  margin-bottom: 16px;
}
.icrm-funnel-bar-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--icrm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}
.icrm-funnel-bar {
  display: flex;
  height: 8px;
  border-radius: var(--icrm-radius-pill);
  overflow: hidden;
  gap: 2px;
}
.icrm-funnel-segment {
  height: 100%;
  border-radius: 2px;
  transition: opacity var(--icrm-duration) var(--icrm-ease), flex var(--icrm-duration) var(--icrm-ease);
  opacity: 0.35;
}
.icrm-funnel-segment.is-active { opacity: 1; }

/* Pipeline detail panel */
.icrm-pipeline-panel {
  background: var(--icrm-surface);
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius);
  box-shadow: var(--icrm-shadow-xs);
  overflow: hidden;
}

.icrm-pipeline-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--icrm-border-soft);
  gap: 12px;
}

.icrm-pipeline-panel-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icrm-pipeline-panel-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--icrm-text);
}

.icrm-pipeline-panel-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--icrm-surface-alt);
  color: var(--icrm-text-soft);
  border-radius: var(--icrm-radius-pill);
  padding: 2px 9px;
  white-space: nowrap;
}

.icrm-pipeline-panel-total {
  font-size: 13px;
  font-weight: 800;
  color: var(--icrm-stage-color, var(--icrm-accent));
  white-space: nowrap;
}

.icrm-pipeline-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.icrm-pipeline-nav-label {
  font-size: 11px;
  color: var(--icrm-text-muted);
}
.icrm-pipeline-nav-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--icrm-border);
  background: var(--icrm-surface);
  cursor: pointer;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--icrm-duration) var(--icrm-ease);
  color: var(--icrm-text-soft);
}
.icrm-pipeline-nav-btn:hover:not(:disabled) { background: var(--icrm-surface-alt); }
.icrm-pipeline-nav-btn:disabled { opacity: .3; cursor: default; }

/* Deal cards grid inside the panel */
.icrm-pipeline-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  padding: 16px 20px;
}

.icrm-pipeline-card {
  background: var(--icrm-surface-alt);
  border: 1px solid var(--icrm-border-soft);
  border-radius: var(--icrm-radius-sm);
  padding: 14px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow var(--icrm-duration) var(--icrm-ease),
              border-color var(--icrm-duration) var(--icrm-ease),
              transform var(--icrm-duration) var(--icrm-ease);
}
.icrm-pipeline-card:hover {
  box-shadow: var(--icrm-shadow);
  border-color: var(--icrm-border);
  transform: translateY(-1px);
  color: inherit;
  text-decoration: none;
}

.icrm-pipeline-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.icrm-pipeline-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--icrm-text);
  line-height: 1.35;
}
.icrm-pipeline-card-amount {
  font-size: 13px;
  font-weight: 800;
  color: var(--icrm-accent);
  white-space: nowrap;
}

.icrm-pipeline-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.icrm-pipeline-chip {
  font-size: 10px;
  background: var(--icrm-surface);
  color: var(--icrm-text-soft);
  border: 1px solid var(--icrm-border-soft);
  border-radius: var(--icrm-radius-sm);
  padding: 2px 7px;
  font-weight: 600;
}

.icrm-pipeline-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--icrm-border-soft);
  padding-top: 9px;
  margin-top: 2px;
}
.icrm-pipeline-card-brand {
  font-size: 11px;
  color: var(--icrm-text-soft);
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icrm-pipeline-brand-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--icrm-stage-color, var(--icrm-accent));
  flex-shrink: 0;
}
.icrm-pipeline-card-date {
  font-size: 10px;
  color: var(--icrm-text-muted);
  white-space: nowrap;
}

.icrm-pipeline-show-more {
  padding: 10px 20px 16px;
  text-align: center;
}
.icrm-pipeline-show-more a {
  font-size: 12px;
  color: var(--icrm-accent);
  border: 1px solid var(--icrm-accent-border);
  border-radius: var(--icrm-radius-sm);
  padding: 7px 20px;
  display: inline-block;
  transition: background var(--icrm-duration) var(--icrm-ease);
}
.icrm-pipeline-show-more a:hover { background: var(--icrm-accent-soft); text-decoration: none; }

/* Empty panel state */
.icrm-pipeline-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--icrm-text-muted);
  font-size: 14px;
}
.icrm-pipeline-empty-icon { font-size: 28px; display: block; margin-bottom: 10px; }

/* Legacy board styles kept for fallback */
.icrm-board-shell {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 270px);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--icrm-border) transparent;
}

.icrm-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.icrm-board-head h2 { font-size: 14px; font-weight: 800; }
.icrm-board-head span {
  background: var(--icrm-surface-alt);
  color: var(--icrm-text-soft);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--icrm-radius-pill);
}

.icrm-board-stack { display: grid; gap: 10px; margin-top: 14px; }

.icrm-board-card {
  background: var(--icrm-surface-alt);
  border: 1px solid var(--icrm-border-soft);
  border-radius: var(--icrm-radius);
  padding: 14px;
  display: grid;
  gap: 10px;
  transition: box-shadow var(--icrm-duration) var(--icrm-ease);
}

.icrm-board-card:hover { box-shadow: var(--icrm-shadow); }

.icrm-board-card strong { display: block; font-size: 14px; font-weight: 700; margin: 0 0 2px; }
.icrm-board-card span   { color: var(--icrm-text-soft); font-size: 13px; margin: 0; }

.icrm-board-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--icrm-text-muted);
  font-size: 12px;
}

.icrm-empty-column {
  color: var(--icrm-text-muted);
  font-size: 13px;
  padding: 16px 0;
  text-align: center;
}

/* ============================================================
   Empty states
   ============================================================ */
.icrm-empty-state {
  display: grid;
  gap: 14px;
  text-align: center;
  min-height: 280px;
  place-content: center;
}

.icrm-empty-state p { color: var(--icrm-text-soft); margin: 0; line-height: 1.7; }

.icrm-empty-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ============================================================
   Forms
   ============================================================ */
.icrm-form { display: grid; gap: 18px; }

.icrm-form-field { display: grid; gap: 7px; }

.icrm-form-field span {
  font-size: 13px;
  font-weight: 700;
  color: var(--icrm-text-soft);
}

.icrm-form-field input,
.icrm-form-field select,
.icrm-form-field textarea {
  width: 100%;
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius);
  padding: 12px 16px;
  background: var(--icrm-surface);
  color: var(--icrm-text);
  font-size: 14px;
  font-weight: 500;
  transition: border-color var(--icrm-duration) var(--icrm-ease),
              box-shadow var(--icrm-duration) var(--icrm-ease);
}

.icrm-form-field input:focus,
.icrm-form-field select:focus,
.icrm-form-field textarea:focus {
  outline: none;
  border-color: var(--icrm-accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.icrm-form-field input::placeholder,
.icrm-form-field textarea::placeholder {
  color: var(--icrm-text-muted);
}

/* Read-only display field (for planned dates etc.) */
.icrm-readonly-field {
  border: 1px solid var(--icrm-border);
  border-radius: var(--icrm-radius);
  padding: 12px 16px;
  background: var(--icrm-surface-alt);
  color: var(--icrm-text-soft);
  font-size: 14px;
  font-weight: 600;
  direction: rtl;
}

/* Form label used outside <label> element */
.icrm-form-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--icrm-text-soft);
}

/* ============================================================
   Sheet / modal overlay
   ============================================================ */
.icrm-quick-add-sheet {
  position: fixed;
  inset: 0;
  background: rgba(30, 18, 24, 0.45);
  backdrop-filter: blur(4px);
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 24px;
}

.icrm-sheet-card { width: min(560px, 100%); padding: 22px; position: relative; z-index: 1; }

.icrm-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.icrm-sheet-close {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--icrm-border);
  background: var(--icrm-surface);
  color: var(--icrm-text-soft);
  padding: 0;
  font-size: 18px;
  transition: background var(--icrm-duration) var(--icrm-ease);
}

.icrm-sheet-close:hover { background: var(--icrm-surface-alt); }

.icrm-quick-add-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.icrm-quick-add-item {
  text-align: right;
  padding: 16px;
  border: 1px solid var(--icrm-border);
  background: var(--icrm-surface);
  border-radius: var(--icrm-radius);
  color: var(--icrm-text);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--icrm-duration) var(--icrm-ease),
              border-color var(--icrm-duration) var(--icrm-ease);
}

.icrm-quick-add-item:hover {
  background: var(--icrm-accent-soft);
  border-color: var(--icrm-accent-border);
  color: var(--icrm-accent);
}

/* ============================================================
   Mobile nav
   ============================================================ */
.icrm-mobile-nav {
  position: fixed;
  right: 0;
  left: 0;
  bottom: 0;
  width: 100vw;
  direction: rtl;
  display: none;
  justify-content: space-around;
  gap: 4px;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgb(255, 253, 249);
  border-top: 1px solid var(--icrm-border);
  z-index: 20;
}

.icrm-mobile-nav-link {
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--icrm-radius);
  color: var(--icrm-text-soft);
  min-width: 56px;
  text-align: center;
}

.icrm-mobile-nav-link.is-active {
  color: var(--icrm-accent);
  background: var(--icrm-accent-soft);
}

.icrm-mobile-nav-link .icrm-nav-icon {
  margin: 0 auto;
}

/* ── Mobile overflow drawer (B-15–B-18) ───────────────────────────────────── */
.icrm-mobile-overflow-drawer {
  position: fixed;
  right: 0;
  width: 100vw;
  bottom: calc(64px + env(safe-area-inset-bottom));
  background: var(--icrm-surface);
  border: 1px solid var(--icrm-border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.10);
  z-index: 25;
  display: none; /* shown by JS toggling hidden attribute */
}
.icrm-mobile-overflow-drawer:not([hidden]) {
  display: block;
}
.icrm-mobile-overflow-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px 12px;
}
.icrm-mobile-overflow-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--icrm-radius);
  color: var(--icrm-text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.icrm-mobile-overflow-link:hover,
.icrm-mobile-overflow-link.is-active {
  background: var(--icrm-accent-soft);
  color: var(--icrm-accent);
}
.icrm-mobile-overflow-link .icrm-nav-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
}
body.icrm-overflow-open::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 24;
}

/* ============================================================
   Subscription / settings panels
   ============================================================ */
.icrm-usage-bar-wrap { margin-bottom: 16px; }
.icrm-usage-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--icrm-text-soft);
  margin-bottom: 6px;
}
.icrm-usage-bar-track {
  height: 8px;
  background: var(--icrm-surface-alt);
  border-radius: var(--icrm-radius-pill);
  overflow: hidden;
}
.icrm-usage-bar-fill {
  height: 100%;
  border-radius: var(--icrm-radius-pill);
  background: var(--icrm-accent);
  transition: width 400ms var(--icrm-ease);
}
.icrm-usage-bar-fill.is-warn { background: var(--icrm-gold); }
.icrm-usage-bar-fill.is-danger { background: var(--icrm-danger); }

.icrm-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: var(--icrm-radius-pill);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--icrm-gold-soft);
  color: var(--icrm-gold);
  border: 1px solid var(--icrm-gold-border);
}

.icrm-plan-badge.is-pro {
  background: var(--icrm-accent-soft);
  color: var(--icrm-accent);
  border-color: var(--icrm-accent-border);
}

.icrm-entitlement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--icrm-border-soft);
  font-size: 14px;
}
.icrm-entitlement-row:last-child { border-bottom: none; }
.icrm-entitlement-available   { color: var(--icrm-success); font-weight: 700; }
.icrm-entitlement-unavailable { color: var(--icrm-text-muted); font-weight: 500; }

/* ============================================================
   Skeleton loading states
   ============================================================ */
@keyframes icrm-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.icrm-skeleton {
  border-radius: var(--icrm-radius-sm);
  background: linear-gradient(90deg, var(--icrm-surface-alt) 25%, var(--icrm-border-soft) 50%, var(--icrm-surface-alt) 75%);
  background-size: 800px 100%;
  animation: icrm-shimmer 1.4s ease-in-out infinite;
}

.icrm-skeleton-line { height: 14px; margin-bottom: 10px; width: 100%; }
.icrm-skeleton-line.is-short { width: 55%; }
.icrm-skeleton-line.is-medium { width: 75%; }

/* ============================================================
   Upgrade prompt (plan limit modal)
   ============================================================ */
.icrm-upgrade-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 18, 24, 0.5);
  backdrop-filter: blur(4px);
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.icrm-upgrade-card {
  background: var(--icrm-surface);
  border: 1px solid var(--icrm-gold-border);
  border-radius: var(--icrm-radius-xl);
  box-shadow: var(--icrm-shadow-lg);
  padding: 32px;
  max-width: 420px;
  width: 100%;
  display: grid;
  gap: 16px;
  text-align: center;
}

.icrm-upgrade-card h2 { margin: 0; font-size: 22px; font-weight: 900; }
.icrm-upgrade-card p  { margin: 0; color: var(--icrm-text-soft); line-height: 1.7; }

.icrm-upgrade-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
  .icrm-app-shell {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
  .icrm-sidebar { display: none; }
  /* Extra bottom padding so content clears the fixed mobile nav bar */
  .icrm-main-column { padding-bottom: 120px; }
  .icrm-topbar {
    align-items: stretch;
    flex-direction: column;
    top: 8px;
  }
  .icrm-grid--dashboard { grid-template-columns: 1fr; }
  .icrm-mobile-nav { display: flex; }
}

/* Compact mobile nav for narrow phones (e.g. Samsung Galaxy S23+, 360px viewport)
   so all 4 primary items + المزيد button fit without clipping.
   Applied at ≤980px (same breakpoint that enables the mobile nav) to keep labels
   from overflowing — Arabic labels like "لوحة المعلومات" force wider items otherwise. */
@media (max-width: 980px) {
  .icrm-mobile-nav { gap: 0; }
  .icrm-mobile-nav-link { min-width: 0; flex: 1 1 0; padding: 8px 2px; font-size: 10px; overflow: hidden; }
  .icrm-mobile-nav-link span:not(.icrm-nav-icon) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
}

@media (max-width: 640px) {
  .icrm-app-shell { padding: 12px; gap: 12px; }
  .icrm-topbar,
  .icrm-panel,
  .icrm-record-card,
  .icrm-metric-card,
  .icrm-board-column,
  .icrm-empty-state { border-radius: var(--icrm-radius); }
  .icrm-topbar-actions { width: 100%; }
  .icrm-topbar-actions .icrm-action-button { flex: 1 1 auto; text-align: center; }
  .icrm-foundation-banner,
  .icrm-list-item,
  .icrm-record-main,
  .icrm-record-meta,
  .icrm-record-actions,
  .icrm-board-head,
  .icrm-deals-toolbar,
  .icrm-sheet-head { flex-direction: column; align-items: stretch; }
  .icrm-quick-add-grid { grid-template-columns: 1fr; }
  .icrm-metric-value { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ── Payments overdue highlight ─────────────────────────────────────────── */
.icrm-highlight-overdue .icrm-list-item:has([data-status="overdue"]) {
  background: #fff8f0;
  border-right: 3px solid #e65100;
  padding-right: 12px;
}

/* ── Settings tabs ──────────────────────────────────────────────────────── */
.icrm-settings-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--icrm-text-muted, #6b7280);
  cursor: pointer;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  direction: rtl;
}
.icrm-settings-tab:hover {
  color: var(--icrm-accent, #7c3aed);
}
.icrm-settings-tab.is-active {
  color: var(--icrm-accent, #7c3aed);
  border-bottom-color: var(--icrm-accent, #7c3aed);
}

/* ============================================================
   Help Centre — topic card grid
   ============================================================ */
.icrm-help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  direction: rtl;
}

.icrm-help-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--icrm-surface, #fff);
  border: 1px solid var(--icrm-border, #e2d5c3);
  border-radius: 16px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.icrm-help-card:hover {
  border-color: var(--icrm-accent, #7c3aed);
  box-shadow: 0 4px 20px rgba(124,58,237,0.1);
  transform: translateY(-2px);
}

.icrm-help-card__icon {
  font-size: 32px;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3e8ff;
  border-radius: 12px;
}

.icrm-help-card__body {
  flex: 1;
  min-width: 0;
}

.icrm-help-card__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--icrm-text, #1e1218);
  margin: 0 0 4px;
  line-height: 1.3;
}

.icrm-help-card__desc {
  font-size: 13px;
  color: var(--icrm-text-soft, #6b5464);
  margin: 0;
  line-height: 1.6;
}

.icrm-help-card__arrow {
  font-size: 18px;
  color: var(--icrm-accent, #7c3aed);
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
}
.icrm-help-card:hover .icrm-help-card__arrow {
  opacity: 1;
  transform: translateX(-4px);
}
