/* AC7 CRM 2026 — single, shared visual layer. Loaded AFTER all legacy styles.
   Functional calendar event colors and custom screen layouts remain untouched. */
:root, html[data-theme="dark"] {
  color-scheme: dark;
  --ac7-primary: #4a91ff;
  --ac7-primary-hover: #6fa8ff;
  --ac7-primary-soft: rgba(74, 145, 255, .15);
  --ac7-bg: #0a1221;
  --ac7-panel: #121f32;
  --ac7-elevated: #182a40;
  --ac7-menu: #0d192b;
  --ac7-field: #101c2e;
  --ac7-border: #29415e;
  --ac7-ink: #ecf4ff;
  --ac7-muted: #a9bcd5;
  --ac7-shadow: 0 15px 40px rgba(0, 0, 0, .15);
  --bg: var(--ac7-bg);
  --surface: var(--ac7-panel);
  --surface2: var(--ac7-elevated);
  --surface3: var(--ac7-elevated);
  --outline: var(--ac7-border);
  --text: var(--ac7-ink);
  --muted: var(--ac7-muted);
  --blue: var(--ac7-primary);
  --pu-bg: var(--ac7-bg);
  --pu-surface: var(--ac7-panel);
  --pu-raised: var(--ac7-elevated);
  --pu-sidebar: var(--ac7-menu);
  --pu-border: var(--ac7-border);
  --pu-text: var(--ac7-ink);
  --pu-muted: var(--ac7-muted);
  --pu-primary: var(--ac7-primary);
  --pu-primary-soft: var(--ac7-primary-soft);
  --pu-table-head: #1a304a;
  --pu-row-hover: #1b3450;
  --pu-row-alt: #14253a;
  --pu-input: var(--ac7-field);
  --pu-button: var(--ac7-elevated);
  --pu-shadow: var(--ac7-shadow);
}
html[data-theme="light"] {
  color-scheme: light;
  --ac7-primary: #1766c7;
  --ac7-primary-hover: #0f54af;
  --ac7-primary-soft: #e6f1ff;
  --ac7-bg: #f3f7fc;
  --ac7-panel: #fff;
  --ac7-elevated: #eef4fc;
  --ac7-menu: #fff;
  --ac7-field: #fff;
  --ac7-border: #d5e2f2;
  --ac7-ink: #142b46;
  --ac7-muted: #536e8d;
  --ac7-shadow: 0 12px 35px rgba(24, 75, 132, .07);
  --bg: var(--ac7-bg);
  --surface: var(--ac7-panel);
  --surface2: var(--ac7-elevated);
  --surface3: var(--ac7-elevated);
  --outline: var(--ac7-border);
  --text: var(--ac7-ink);
  --muted: var(--ac7-muted);
  --blue: var(--ac7-primary);
  --pu-bg: var(--ac7-bg);
  --pu-surface: var(--ac7-panel);
  --pu-raised: var(--ac7-elevated);
  --pu-sidebar: var(--ac7-menu);
  --pu-border: var(--ac7-border);
  --pu-text: var(--ac7-ink);
  --pu-muted: var(--ac7-muted);
  --pu-primary: var(--ac7-primary);
  --pu-primary-soft: var(--ac7-primary-soft);
  --pu-table-head: #e8f1fb;
  --pu-row-hover: #edf5ff;
  --pu-row-alt: #f7faff;
  --pu-input: var(--ac7-field);
  --pu-button: var(--ac7-elevated);
  --pu-shadow: var(--ac7-shadow);
}
html,body { min-width: 0; }
body { background: var(--ac7-bg); color: var(--ac7-ink); font-family: "Segoe UI", Tahoma, Arial, sans-serif; }
.app-shell, .app-shell .main { background: var(--ac7-bg); color: var(--ac7-ink); }
.app-shell .sidebar { background: var(--ac7-menu); border-color: var(--ac7-border); }
.app-shell .topbar { background: var(--ac7-panel); border-color: var(--ac7-border); }
.app-shell .brand small, .app-shell .nav-title, .app-shell .crumb, .muted,
.app-shell .section-header p { color: var(--ac7-muted); }
.app-shell .navigation .nav-button { color: var(--ac7-muted); }
.app-shell .navigation .nav-button:hover, .app-shell .navigation .nav-button.active {
  background: var(--ac7-primary-soft); color: var(--ac7-ink); border-color: var(--ac7-border);
}
.app-shell .navigation .nav-button.active { box-shadow: inset -3px 0 0 var(--ac7-primary); }
.app-shell .panel, .app-shell .kpi, .app-shell .settings-row,
#modal-host .modal, .app-shell .data-table-wrap {
  background: var(--ac7-panel); color: var(--ac7-ink);
  border-color: var(--ac7-border); box-shadow: var(--ac7-shadow); border-radius: 14px;
}
.app-shell .kpi { background: var(--ac7-panel); }
.app-shell .kpi strong, .app-shell h1, .app-shell h2,
.app-shell h3, .app-shell .name-cell { color: var(--ac7-ink); }
.app-shell .kpi .glyph, .app-shell .acticon {
  background: var(--ac7-primary-soft); color: var(--ac7-primary);
}
.app-shell .btn, #modal-host .btn, .startup .btn {
  border: 1px solid var(--ac7-border); background: var(--ac7-elevated);
  color: var(--ac7-ink); border-radius: 10px;
}
.app-shell .btn:hover, #modal-host .btn:hover, .startup .btn:hover {
  background: var(--ac7-primary-soft); border-color: var(--ac7-primary);
}
.app-shell .btn.primary, #modal-host .btn.primary, .startup .btn.primary {
  background: linear-gradient(125deg, #2583ef, #165ec7);
  color: #fff; border-color: #3489e7;
}
.app-shell .btn.primary:hover, #modal-host .btn.primary:hover, .startup .btn.primary:hover {
  background: linear-gradient(125deg, #3e9bff, #2474d7); color:#fff;
}
.app-shell .field input, .app-shell .field select, .app-shell .field textarea,
#modal-host .field input, #modal-host .field select, #modal-host .field textarea,
.startup .field input, .app-shell .search, .app-shell .filterselect {
  background: var(--ac7-field); color: var(--ac7-ink);
  border: 1px solid var(--ac7-border); border-radius: 10px;
}
.app-shell .field label, #modal-host .field label, .startup .field label {
  color: var(--ac7-ink);
}
.app-shell :is(input, select, textarea)::placeholder, #modal-host :is(input, select, textarea)::placeholder {
  color: var(--ac7-muted); opacity: .9;
}
.app-shell :is(input, select, textarea):focus-visible,
#modal-host :is(input, select, textarea):focus-visible,
.startup :is(input, select, textarea):focus-visible,
.app-shell :is(button,a):focus-visible, #modal-host :is(button,a):focus-visible {
  outline: 2px solid var(--ac7-primary); outline-offset: 2px;
}
.app-shell .data-table-wrap { overflow-x: auto; }
.app-shell .data-table-wrap thead th { background: var(--pu-table-head); color:var(--ac7-ink); }
.app-shell .data-table-wrap tbody td { border-color: var(--ac7-border); }
.app-shell .data-table-wrap tbody tr:nth-child(even) { background: var(--pu-row-alt); }
.app-shell .data-table-wrap tbody tr:hover { background: var(--pu-row-hover); }
#modal-host .modal, .modal { background: var(--ac7-panel); color: var(--ac7-ink); }
#modal-host .modal-header, #modal-host .modal-footer, .modal-footer { border-color: var(--ac7-border); }
#modal-host .modal-footer, .modal-footer { background: var(--ac7-panel); }
.app-shell .detail { background: var(--ac7-elevated); color: var(--ac7-ink); }
/* Login is intentionally styled separately: the app shell isn't present yet. */
#app > .startup { background:var(--ac7-panel); border:1px solid var(--ac7-border);
  box-shadow:var(--ac7-shadow); border-radius:22px; padding:28px 32px 35px;
  max-width:min(440px,calc(100% - 30px)) !important; }
#app > .startup h2 {color:var(--ac7-ink);font-size:22px;margin:8px 0;}
#app > .startup p {color:var(--ac7-muted);line-height:1.85;}
#app > .startup .field input {width:100%; min-height:44px; padding:10px 12px;}
#app > .startup .crm-login-logo {width:120px;height:100px;object-fit:contain;}
/* Layout safety across all pages and custom modules. */
.app-shell .content, .app-shell .main, #modal-host .modal-content { min-width:0; }
.app-shell .panel, .app-shell .form-grid > *, .app-shell .panel-grid > * { min-width:0; }
.app-shell .toolbar, .app-shell .section-header, .app-shell .topbar-right { flex-wrap:wrap; }
.app-shell .data-table-wrap { max-width:100%; }
@media(max-width:900px) {
  .app-shell .content {padding:20px 16px;}
  .app-shell .topbar {height:auto; min-height:70px; padding:14px 16px;}
  .app-shell .section-header {align-items:flex-start;}
  .app-shell .section-header .actions {flex-wrap:wrap;}
  .app-shell .panel-grid {grid-template-columns:minmax(0,1fr);}
}
@media(max-width:650px) {
  .app-shell .content {padding:16px 12px;}
  .app-shell .kpi-grid {grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
  .app-shell .kpi {padding:13px;min-height:110px;}
  .app-shell .kpi strong {font-size:26px;}
  .app-shell .section-header h2 {font-size:20px;}
  #modal-host .modal-content {padding:16px 12px;}
  #modal-host .form-grid {grid-template-columns:1fr;}
  #modal-host .field.full {grid-column:1/-1;}
  .app-shell .toolbar > *, .app-shell .toolbar .search {max-width:100%;}
  #app > .startup {margin:5vh auto !important;padding:24px 20px;}

  /* Team Day Responsive Enhancements */
  .ac7-cards-grid, .ac7-work-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .ac7-today-kpi-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .ac7-action-card {
    padding: 13px;
  }
  .btn-card-action {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
    padding: 8px 6px;
  }
  .ac7-card-journey .ac7-journey-desc {
    white-space: normal;
  }
}
@media(max-width:390px) {
  .app-shell .kpi-grid {grid-template-columns:1fr;}
}

/* Contract document permissions */
.app-shell .contract-access-panel { border:1px solid var(--ac7-border); background:var(--ac7-elevated);
  padding:15px; margin-top:18px; border-radius:12px; }
.app-shell .contract-access-panel h4 { color:var(--ac7-ink); font-size:14px; margin:0 0 6px; }
.app-shell .contract-access-panel p { margin:0 0 10px; }
.app-shell .contract-access-row { display:flex; justify-content:space-between; align-items:center;
  gap:12px; padding:9px 0; border-top:1px solid var(--ac7-border); flex-wrap:wrap; }

/* Password eye and workers-count field */
.ac7-password-field{display:block;width:100%;position:relative;min-width:0}
.ac7-password-field>input{width:100%;box-sizing:border-box;padding-inline-end:46px!important}
.ac7-password-toggle{position:absolute;inset-inline-end:5px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:0;border-radius:8px;background:transparent;color:var(--ac7-muted);cursor:pointer}
.ac7-password-toggle:hover,.ac7-password-toggle:focus-visible{background:var(--ac7-primary-soft);color:var(--ac7-primary)}
.ac7-password-field input::-ms-reveal{display:none}
.ac7-temp-password-row{display:grid;gap:7px;max-width:420px;margin:12px 0}
.ac7-temp-password-row input{background:var(--ac7-field);color:var(--ac7-ink);border:1px solid var(--ac7-border);border-radius:10px;padding:11px;min-height:44px;width:100%}
#modal-host { position: relative !important; z-index: 10050 !important; }
#modal-host .overlay { z-index: 10050 !important; }
#modal-host .modal {
  z-index: 10051 !important;
  height: auto !important;
  max-height: calc(100vh - 40px) !important;
  display: flex !important;
  flex-direction: column !important;
}
#modal-host .modal-content {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}
#modal-host .modal-footer {
  flex-shrink: 0 !important;
  margin-top: auto !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 2 !important;
}
#modal-host .form-grid>.ac7-workers-field{grid-column:span 1;border:1px solid var(--ac7-border);border-radius:10px;background:var(--ac7-field);padding:10px 12px;gap:6px}
.ac7-workers-heading{display:flex;align-items:center;gap:10px}
.ac7-workers-icon{display:inline-grid;place-items:center;width:36px;height:36px;background:var(--ac7-primary-soft);border-radius:10px;font-size:21px}
.ac7-workers-help{color:var(--ac7-muted);font-size:12px}
.ac7-shared-factories-hint{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin:-3px 0 15px;color:var(--ac7-muted);font-size:12px}

/* =========================================================
   AC7 CRM Phase 1: Daily Workspace & Factory Timeline Styles
   ========================================================= */

/* KPI Bar */
.ac7-today-kpi-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}
.kpi-pill {
  background: var(--ac7-panel);
  border: 1px solid var(--ac7-border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: var(--ac7-shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.kpi-pill:hover {
  transform: translateY(-2px);
  border-color: var(--ac7-primary);
}
.kpi-pill .kpi-num {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ac7-ink);
}
.kpi-pill .kpi-lbl {
  font-size: 12px;
  color: var(--ac7-muted);
  margin-top: 4px;
  font-weight: 600;
}
.kpi-pill.kpi-total .kpi-num { color: var(--ac7-primary); }
.kpi-pill.kpi-completed .kpi-num { color: #10b981; }
.kpi-pill.kpi-remaining .kpi-num { color: #f59e0b; }
.kpi-pill.kpi-overdue .kpi-num { color: #ef4444; }
.kpi-pill.kpi-overdue.alert {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}
.kpi-pill.kpi-tomorrow .kpi-num { color: #8b5cf6; }

/* Tab Switcher */
.ac7-tab-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--ac7-border);
  padding-bottom: 10px;
  overflow-x: auto;
}
.ac7-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ac7-muted);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.ac7-tab-btn:hover {
  background: var(--ac7-primary-soft);
  color: var(--ac7-ink);
}
.ac7-tab-btn.active {
  background: var(--ac7-primary-soft);
  color: var(--ac7-primary);
  border-color: var(--ac7-primary);
  box-shadow: 0 4px 12px rgba(74, 145, 255, 0.15);
}

/* Action Cards */
.ac7-work-section {
  margin-bottom: 26px;
}
.ac7-work-section h3 {
  font-size: 16px;
  margin: 0;
  color: var(--ac7-ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ac7-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.badge-dot.red { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
.badge-dot.warning, .badge-dot.amber { background: #f59e0b; }
.badge-dot.success { background: #10b981; }
.badge-dot.primary { background: var(--ac7-primary); }
.badge-dot.purple { background: #8b5cf6; }
.badge-dot.dim { background: var(--ac7-muted); }

.ac7-cards-grid, .ac7-work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.ac7-action-card {
  background: var(--ac7-panel);
  border: 1px solid var(--ac7-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--ac7-shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative;
  overflow: hidden;
}
.ac7-action-card:hover {
  transform: translateY(-2px);
  border-color: var(--ac7-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.ac7-action-card.is-overdue {
  border-right: 4px solid #ef4444;
}
.ac7-action-card.is-done {
  opacity: 0.7;
  border-right: 4px solid #10b981;
}
.ac7-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ac7-card-time {
  font-size: 11px;
  color: var(--ac7-muted);
  font-weight: 600;
}
.ac7-card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ac7-ink);
  line-height: 1.4;
}
.ac7-card-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--ac7-muted);
  margin-bottom: 10px;
}
.ac7-meta-item b {
  color: var(--ac7-ink);
}
.ac7-meta-item.phone-pill {
  font-family: monospace;
  font-size: 12px;
  direction: ltr;
  text-align: right;
}
.ac7-card-notes {
  font-size: 12px;
  color: var(--ac7-muted);
  background: var(--ac7-elevated);
  padding: 8px 10px;
  border-radius: 8px;
  margin: 6px 0;
  line-height: 1.5;
}
.ac7-card-result {
  font-size: 12px;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  padding: 6px 10px;
  border-radius: 8px;
  margin-top: 6px;
}

/* Card Journey Box (Last Action & Next Action) */
.ac7-card-journey {
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--ac7-elevated);
  border: 1px solid var(--ac7-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  line-height: 1.4;
}
.ac7-journey-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ac7-journey-tag {
  font-weight: 700;
  white-space: nowrap;
}
.ac7-journey-tag.tag-last {
  color: var(--ac7-muted);
}
.ac7-journey-tag.tag-next {
  color: var(--ac7-primary);
}
.ac7-journey-desc {
  flex: 1;
  color: var(--ac7-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.ac7-journey-time {
  font-size: 11px;
  color: var(--ac7-muted);
  white-space: nowrap;
  font-family: monospace;
}

/* Badges */
.ac7-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-primary { background: var(--ac7-primary-soft); color: var(--ac7-primary); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.badge-dim { background: var(--ac7-elevated); color: var(--ac7-muted); }

/* Quick Action Buttons */
.ac7-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--ac7-border);
}
.btn-card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--ac7-border);
  background: var(--ac7-elevated);
  color: var(--ac7-ink);
  transition: all .15s ease;
  line-height: 1.2;
}
.btn-card-action:hover {
  transform: translateY(-1px);
}
.btn-card-action.call {
  background: #1e3a8a;
  color: #bfdbfe;
  border-color: #3b82f6;
}
.btn-card-action.call:hover {
  background: #2563eb;
  color: #fff;
}
.btn-card-action.wa {
  background: #064e3b;
  color: #a7f3d0;
  border-color: #10b981;
}
.btn-card-action.wa:hover {
  background: #059669;
  color: #fff;
}
.btn-card-action.copy:hover {
  background: var(--ac7-primary-soft);
  color: var(--ac7-primary);
}
.btn-card-action.factory:hover {
  background: var(--ac7-elevated);
  border-color: var(--ac7-primary);
}
.btn-card-action.record {
  background: linear-gradient(125deg, #2583ef, #165ec7);
  color: #fff;
  border-color: #3489e7;
}
.btn-card-action.record:hover {
  background: linear-gradient(125deg, #3e9bff, #2474d7);
}
.btn-card-action.confirm-done {
  background: linear-gradient(125deg, #059669, #047857);
  color: #fff;
  border-color: #10b981;
}
.btn-card-action.confirm-done:hover {
  background: linear-gradient(125deg, #10b981, #059669);
  border-color: #34d399;
}
.btn-card-action.postpone:hover {
  border-color: #f59e0b;
  color: #f59e0b;
}

/* Light mode adjustments for Call and WhatsApp buttons */
html[data-theme="light"] .btn-card-action.call {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
html[data-theme="light"] .btn-card-action.call:hover {
  background: #2563eb;
  color: #fff;
}
html[data-theme="light"] .btn-card-action.wa {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}
html[data-theme="light"] .btn-card-action.wa:hover {
  background: #10b981;
  color: #fff;
}

/* Factory Profile Top Card & KPIs */
.ac7-factory-header-card {
  border-top: 4px solid var(--ac7-primary);
}
.ac7-factory-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.ac7-factory-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ac7-factory-kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--ac7-border);
}
.ac7-f-kpi {
  background: var(--ac7-elevated);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--ac7-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ac7-f-kpi small {
  font-size: 11px;
  color: var(--ac7-muted);
}
.ac7-f-kpi strong {
  font-size: 13px;
  color: var(--ac7-ink);
}
.ac7-f-sub {
  font-size: 11px;
  color: var(--ac7-muted);
}

/* Contacts Cards Grid */
.ac7-contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.ac7-contact-card {
  background: var(--ac7-elevated);
  border: 1px solid var(--ac7-border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}
.ac7-contact-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ac7-contact-info b {
  font-size: 14px;
  color: var(--ac7-ink);
}
.ac7-contact-info .phone-text {
  font-size: 12px;
  color: var(--ac7-muted);
  font-family: monospace;
}
.ac7-contact-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Timeline Components */
.ac7-timeline-panel {
  border-top: 3px solid #8b5cf6;
}
.ac7-timeline-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.ac7-timeline-card {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: var(--ac7-elevated);
  border: 1px solid var(--ac7-border);
  border-radius: 12px;
  transition: transform .12s ease, border-color .12s ease;
}
.ac7-timeline-card:hover {
  transform: translateX(-3px);
  border-color: var(--ac7-primary);
}
.ac7-tl-icon-col {
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}
.ac7-tl-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--ac7-panel);
  border: 1px solid var(--ac7-border);
}
.ac7-timeline-card.type-call .ac7-tl-icon { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.ac7-timeline-card.type-whatsapp .ac7-tl-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.ac7-timeline-card.type-meeting .ac7-tl-icon { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.ac7-timeline-card.type-task .ac7-tl-icon { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.ac7-timeline-card.type-change .ac7-tl-icon { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.ac7-timeline-card.type-contract .ac7-tl-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.ac7-tl-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ac7-tl-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--ac7-muted);
}
.ac7-tl-time {
  font-weight: 600;
}
.ac7-tl-actor {
  color: var(--ac7-ink);
  font-weight: 600;
}
.ac7-tl-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ac7-ink);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ac7-tl-result {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--ac7-panel);
  border: 1px solid var(--ac7-border);
  color: var(--ac7-primary);
}
.ac7-tl-details {
  font-size: 12px;
  color: var(--ac7-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ac7-tl-next {
  font-size: 11px;
  color: #10b981;
  font-weight: 600;
}

/* ====================================================
   Phase 2 Part 2: Factories Grid & Opportunities CSS
   ==================================================== */
.ac7-factories-kpi-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}
.ac7-factories-kpi-card {
  background: var(--ac7-panel);
  border: 1px solid var(--ac7-border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
  user-select: none;
}
.ac7-factories-kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--ac7-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.ac7-factories-kpi-card.active {
  border-color: var(--ac7-primary);
  background: var(--ac7-primary-soft);
  box-shadow: 0 0 0 2px var(--ac7-primary);
}
.ac7-factories-kpi-card .kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ac7-factories-kpi-card .kpi-glyph {
  font-size: 20px;
  line-height: 1;
}
.ac7-factories-kpi-card .kpi-val {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ac7-ink);
}
.ac7-factories-kpi-card .kpi-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ac7-muted);
}
.ac7-factories-kpi-card.kpi-total .kpi-val { color: var(--ac7-primary); }
.ac7-factories-kpi-card.kpi-unassigned .kpi-val { color: #f59e0b; }
.ac7-factories-kpi-card.kpi-overdue .kpi-val { color: #ef4444; }
.ac7-factories-kpi-card.kpi-interested .kpi-val { color: #8b5cf6; }
.ac7-factories-kpi-card.kpi-negotiating .kpi-val { color: #f97316; }
.ac7-factories-kpi-card.kpi-contracted .kpi-val { color: #10b981; }

/* Filter Panel */
.ac7-filter-panel {
  background: var(--ac7-panel);
  border: 1px solid var(--ac7-border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ac7-filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: flex-end;
}
.ac7-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ac7-filter-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ac7-muted);
}
.ac7-filter-group select,
.ac7-filter-group input {
  height: 38px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--ac7-border);
  background: var(--ac7-field);
  color: var(--ac7-ink);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.ac7-filter-group select:focus,
.ac7-filter-group input:focus {
  border-color: var(--ac7-primary);
}
.ac7-filter-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 6px;
  border-top: 1px dashed var(--ac7-border);
}
.ac7-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--ac7-border);
  background: var(--ac7-panel);
  color: var(--ac7-ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.ac7-toggle-btn:hover {
  border-color: var(--ac7-primary);
}
.ac7-toggle-btn.active {
  background: var(--ac7-primary);
  color: #fff;
  border-color: var(--ac7-primary);
}
.ac7-toggle-btn.active.danger {
  background: #ef4444;
  border-color: #ef4444;
}

/* Pagination bar */
.ac7-pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--ac7-panel);
  border: 1px solid var(--ac7-border);
  border-radius: 12px;
  font-size: 13px;
}
.ac7-page-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}
.ac7-page-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--ac7-border);
  background: var(--ac7-elevated);
  color: var(--ac7-ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.ac7-page-btn.active {
  background: var(--ac7-primary);
  color: #fff;
  border-color: var(--ac7-primary);
}
.ac7-page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Quick Action Group in Table Cells */
.ac7-quick-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}
.ac7-btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--ac7-border);
  background: var(--ac7-elevated);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.12s ease;
  color: var(--ac7-ink);
  text-decoration: none;
}
.ac7-btn-icon:hover {
  transform: scale(1.08);
  border-color: var(--ac7-primary);
  color: var(--ac7-primary);
}
.ac7-btn-icon.wa { color: #10b981; }
.ac7-btn-icon.wa:hover { background: #10b981; color: #fff; }
.ac7-btn-icon.call { color: #3b82f6; }
.ac7-btn-icon.call:hover { background: #3b82f6; color: #fff; }
.ac7-btn-icon.factory { color: #8b5cf6; }
.ac7-btn-icon.factory:hover { background: #8b5cf6; color: #fff; }

.ac7-subtext {
  font-size: 11px;
  color: var(--ac7-muted);
  display: block;
  margin-top: 2px;
}


/* ============================================================
   AC7 CRM — Redesigned Factories Table & Mobile Responsive Cards
   ============================================================ */

.ac7-factories-table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--ac7-border);
  border-radius: 12px;
  background: var(--ac7-panel);
  box-shadow: var(--ac7-shadow);
  max-width: 100%;
}

.ac7-factories-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: right;
  white-space: nowrap;
}

.ac7-factories-table th,
.ac7-factories-table td {
  padding: 6px 10px !important;
  font-size: 12px;
  vertical-align: middle;
  border-top: 1px solid var(--ac7-border);
  line-height: 1.35;
}

.ac7-factories-table thead th {
  background: var(--pu-table-head, #1a304a);
  color: var(--ac7-muted, #a9bcd5);
  font-weight: 700;
  border-top: none;
  font-size: 11.5px;
  letter-spacing: 0.3px;
  padding: 10px 10px !important;
}

.ac7-factories-table tbody tr:nth-child(even) {
  background: var(--pu-row-alt, #14253a);
}

.ac7-factories-table tbody tr:hover {
  background: var(--pu-row-hover, #1b3450);
}

/* Sticky Action Column on the Left in RTL */
.ac7-factories-table th.ac7-col-actions,
.ac7-factories-table td.ac7-col-actions {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--ac7-panel, #121f32);
  box-shadow: -4px 0 10px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.ac7-factories-table thead th.ac7-col-actions {
  background: var(--pu-table-head, #1a304a);
}

.ac7-factories-table tbody tr:nth-child(even) td.ac7-col-actions {
  background: var(--pu-row-alt, #14253a);
}

.ac7-factories-table tbody tr:hover td.ac7-col-actions {
  background: var(--pu-row-hover, #1b3450);
}

html[data-theme="light"] .ac7-factories-table th.ac7-col-actions,
html[data-theme="light"] .ac7-factories-table td.ac7-col-actions {
  background: #fff;
  box-shadow: -4px 0 10px rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .ac7-factories-table thead th.ac7-col-actions {
  background: #eef4fc;
}

html[data-theme="light"] .ac7-factories-table tbody tr:nth-child(even) td.ac7-col-actions {
  background: #f8fafc;
}

html[data-theme="light"] .ac7-factories-table tbody tr:hover td.ac7-col-actions {
  background: #f1f5f9;
}

/* Media queries for Mobile cards layout */
@media (min-width: 769px) {
  .ac7-factories-cards {
    display: none !important;
  }
  .ac7-factories-table-wrap {
    display: block !important;
  }
}

@media (max-width: 768px) {
  .ac7-factories-table-wrap {
    display: none !important;
  }
  .ac7-factories-cards {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 12px;
  }
}


/* ============================================================
   AC7 CRM — Factory Brief Card (نبذة سريعة عن المصنع)
   ============================================================ */

.ac7-factory-brief-card {
  background: var(--ac7-panel, #121f32);
  border: 1px solid var(--ac7-border, #29415e);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

.ac7-brief-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ac7-border, #29415e);
  flex-wrap: wrap;
  gap: 8px;
}

.ac7-brief-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ac7-brief-icon {
  font-size: 22px;
  line-height: 1;
}

.ac7-brief-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--ac7-ink, #ecf4ff);
}

.ac7-brief-sub {
  font-size: 12px;
  color: var(--ac7-muted, #a9bcd5);
  display: block;
  margin-top: 2px;
}

.ac7-brief-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 18px;
}

@media (max-width: 992px) {
  .ac7-brief-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .ac7-brief-grid {
    grid-template-columns: 1fr;
  }
}

.ac7-brief-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--ac7-field, #101c2e);
  border: 1px solid var(--ac7-border, #29415e);
  border-radius: 8px;
  padding: 8px 12px;
}

.ac7-brief-label {
  font-size: 11px;
  color: var(--ac7-muted, #a9bcd5);
  font-weight: 600;
}

.ac7-brief-val {
  font-size: 13px;
  color: var(--ac7-ink, #ecf4ff);
  font-weight: 700;
}

.ac7-brief-notes-wrap {
  background: var(--ac7-field, #101c2e);
  border: 1px solid var(--ac7-border, #29415e);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.ac7-brief-notes-icon {
  font-size: 18px;
  line-height: 1.2;
}

.ac7-brief-notes-content {
  flex: 1;
}

.ac7-brief-notes-label {
  font-size: 11px;
  color: var(--ac7-muted, #a9bcd5);
  font-weight: 700;
  display: block;
  margin-bottom: 3px;
}

.ac7-brief-notes-text {
  font-size: 12.5px;
  color: var(--ac7-ink, #ecf4ff);
  line-height: 1.5;
  white-space: pre-wrap;
}

.ac7-brief-notes-text.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ac7-brief-notes-toggle {
  background: transparent;
  border: none;
  color: var(--ac7-primary, #4a91ff);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0 0 0;
  display: inline-block;
}

/* ==========================================================================
   AC7 CRM — Comprehensive Light Mode & Autocomplete Polishing
   Ensures zero dark rogue panels in Light Mode across all modals and popups
   ========================================================================== */

/* Activity follow-up autocomplete panel */
.afu-factory-results {
  background: var(--ac7-panel, #121f32);
  color: var(--ac7-ink, #ecf4ff);
  border: 1px solid var(--ac7-border, #29415e);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.afu-factory-option {
  color: var(--ac7-ink, #ecf4ff);
}

.afu-factory-option:hover,
.afu-factory-option:focus {
  background: var(--ac7-primary-soft, rgba(74, 145, 255, .15)) !important;
  color: var(--ac7-primary, #4a91ff) !important;
}

/* System-wide Light Mode Overrides for Autocomplete & Modals */
html[data-theme="light"] .afu-factory-results {
  background: #ffffff !important;
  color: #142b46 !important;
  border-color: #d5e2f2 !important;
  box-shadow: 0 12px 30px rgba(20, 43, 70, 0.12) !important;
}

html[data-theme="light"] .afu-factory-option {
  color: #142b46 !important;
  background: transparent !important;
}

html[data-theme="light"] .afu-factory-option:hover,
html[data-theme="light"] .afu-factory-option:focus {
  background: #e6f1ff !important;
  color: #1766c7 !important;
}

html[data-theme="light"] #modal-host .modal,
html[data-theme="light"] .modal {
  background: #ffffff !important;
  color: #142b46 !important;
  border-color: #d5e2f2 !important;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.16) !important;
}

html[data-theme="light"] #modal-host .modal-header,
html[data-theme="light"] #modal-host .modal-footer,
html[data-theme="light"] .modal-header,
html[data-theme="light"] .modal-footer {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  color: #142b46 !important;
}

html[data-theme="light"] #modal-host .field input,
html[data-theme="light"] #modal-host .field select,
html[data-theme="light"] #modal-host .field textarea,
html[data-theme="light"] .form-grid input,
html[data-theme="light"] .form-grid select,
html[data-theme="light"] .form-grid textarea {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] #modal-host .field input:focus,
html[data-theme="light"] #modal-host .field select:focus,
html[data-theme="light"] #modal-host .field textarea:focus {
  border-color: #1766c7 !important;
  outline: 2px solid rgba(23, 102, 199, 0.2) !important;
}

html[data-theme="light"] select option {
  background: #ffffff;
  color: #142b46;
}

/* Standalone Task Detail Page & Real Links */
.ac7-task-detail-container {
  width: 100%;
  box-sizing: border-box;
}

a.btn-card-action,
a.nav-button,
a.ac7-meta-company-link {
  cursor: pointer;
  text-decoration: none;
}

a.btn-card-action.task-details {
  background: rgba(99, 102, 241, 0.12);
  color: var(--ac7-primary, #60a5fa);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

html[data-theme="light"] a.btn-card-action.task-details {
  background: #eef2ff !important;
  color: #4338ca !important;
  border-color: #c7d2fe !important;
}

a.btn-card-action.task-details:hover {
  background: var(--ac7-primary, #2563eb);
  color: #ffffff;
}

html[data-theme="light"] a.btn-card-action.task-details:hover {
  background: #4338ca !important;
  color: #ffffff !important;
}


/* ==========================================================================
   AC7 CRM Silky Soft Transitions + Scroll Reveal Animations
   ========================================================================== */

/* 1. Calm, Pure Opacity Fade for the Page Container (No Jerky Movements) */
@keyframes ac7SilkyPageEnter {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.content {
  animation: ac7SilkyPageEnter 0.22s ease-out both;
  will-change: opacity;
}

/* 2. Scroll Reveal: Visible immediately without blocking or occluding content */
.ac7-scroll-reveal {
  opacity: 1 !important;
  transform: none !important;
  visibility: visible !important;
}

.ac7-scroll-reveal.ac7-revealed {
  opacity: 1 !important;
  transform: none !important;
  visibility: visible !important;
}

/* 3. Modals and Overlays */
@keyframes ac7ModalSilkyEnter {
  0% {
    opacity: 0;
    transform: scale(0.98);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes ac7OverlaySilkyEnter {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.overlay {
  animation: ac7OverlaySilkyEnter 0.18s ease-out both;
}

.modal {
  animation: ac7ModalSilkyEnter 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
  will-change: opacity, transform;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .content,
  .ac7-scroll-reveal,
  .overlay,
  .modal {
    animation: none !important;
    transform: none !important;
    transition: none !important;
    opacity: 1 !important;
  }
}
