/* Clients workspace */
#view-clients .grid{
  display:grid!important;
  grid-template-columns:minmax(300px,360px) minmax(0,1fr)!important;
  gap:18px!important;
  align-items:start!important;
}

#view-clients .clients-column{
  grid-column:1!important;
  grid-row:1 / span 2!important;
}

#view-clients .profile-column,
#view-clients .meta-column{
  grid-column:2!important;
  min-width:0!important;
}

#view-clients .profile-column{
  grid-row:1!important;
}

#view-clients .meta-column{
  grid-row:2!important;
  margin-top:0;
}

#view-clients .card{
  width:100%!important;
  max-width:none!important;
  min-width:0!important;
}

#view-clients .card h2{
  margin-top:0;
}

#view-clients .clients-column,
#view-clients .profile-column,
#view-clients .meta-column{
  display:flex;
  flex-direction:column;
  gap:18px;
}

#view-clients .clients-column > .card,
#view-clients .profile-column > .card,
#view-clients .meta-column > .card{
  height:auto!important;
  margin:0!important;
}

#view-clients .meta-card,
#view-clients .meta-sync-card{
  margin-bottom:18px;
}

.client-profile-header{
  min-height:118px;
  display:flex;
  align-items:center;
  gap:18px;
  background:#fff;
  border:1px solid var(--line,#d9dec3);
  border-radius:18px;
  padding:20px;
  margin-bottom:14px;
  box-shadow:0 16px 38px rgba(31,41,55,.06);
}

.client-hero-avatar,
.client-list-avatar{
  display:inline-grid;
  place-items:center;
  flex:0 0 auto;
  border-radius:999px;
  background:#8ab800;
  color:#fff;
  font-weight:950;
}

.client-hero-avatar{
  width:62px;
  height:62px;
  font-size:20px;
}

.client-hero-main{
  flex:1;
  min-width:0;
}

.client-hero-main h2{
  margin:0;
  color:#121827;
  font-size:25px;
  line-height:1.1;
}

.client-hero-main p{
  margin:5px 0 10px;
  color:#667085;
}

.client-hero-badges,
.client-list-main > span{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  align-items:center;
}

.client-hero-badges > span,
.client-platform-pill{
  display:inline-flex;
  align-items:center;
  min-height:22px;
  padding:4px 8px;
  border-radius:999px;
  font-size:11px;
  font-weight:900;
  background:#f3f6e3;
  color:#596600;
}

.client-platform-pill.ok{
  background:#eef8e9;
  color:#2e7d32;
}

.client-platform-pill.muted{
  background:#f4f4f5;
  color:#98a2b3;
}

.client-tabs{
  display:flex;
  gap:8px;
  background:#fff;
  border:1px solid var(--line,#d9dec3);
  border-radius:16px;
  padding:6px;
  margin-bottom:14px;
}

.client-tab-btn{
  flex:0 0 auto;
  border:0;
  background:transparent;
  color:#667085;
  padding:10px 16px;
  border-radius:12px;
  font-weight:950;
}

.client-tab-btn.active{
  background:#eef1d2;
  color:#445000;
}

.client-tab-panel{
  display:none;
}

.client-tab-panel.active{
  display:block;
}

#clientsList{
  display:grid;
  gap:10px;
  max-height:680px;
  overflow:auto;
  padding-right:4px;
}

#clientsList::-webkit-scrollbar{
  width:8px;
}

#clientsList::-webkit-scrollbar-thumb{
  background:#d9dec3;
  border-radius:999px;
}

#clientsList::-webkit-scrollbar-track{
  background:transparent;
}

.client-list-card{
  width:100%;
  display:grid;
  grid-template-columns:42px minmax(0,1fr) 8px;
  gap:12px;
  align-items:center;
  text-align:left;
  background:#fff;
  border:1px solid var(--line,#d9dec3);
  border-radius:16px;
  padding:13px;
  box-shadow:none;
}

.client-list-card.active{
  border-color:#8ab800;
  background:#fbfdf2;
  box-shadow:0 10px 26px rgba(138,184,0,.12);
}

.client-list-avatar{
  width:42px;
  height:42px;
  font-size:13px;
}

.client-list-main{
  min-width:0;
  display:grid;
  gap:4px;
}

.client-list-main strong{
  color:#121827;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.client-list-main small{
  color:#667085;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.client-list-card i{
  width:8px;
  height:8px;
  border-radius:999px;
  background:#8ab800;
}

.client-account-summary{
  margin-top:6px;
  color:#596600;
  font-weight:800;
}

.account-availability-toggle{
  display:flex;
  align-items:center;
  gap:9px;
  margin:12px 0;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fbfcf3;
  color:#3f4609;
  font-size:12px;
  font-weight:850;
  cursor:pointer;
}

.account-availability-toggle input{
  width:auto;
  margin:0;
}

.account-selection-controls{
  transition:opacity .16s ease;
}

.account-selection-controls.disabled{
  opacity:.5;
}

.account-selection-controls.disabled label,
.account-selection-controls.disabled .small{
  color:#667085;
}

@media(max-width:1100px){
  #view-clients .grid{
    grid-template-columns:1fr!important;
  }
  #view-clients .clients-column,
  #view-clients .profile-column,
  #view-clients .meta-column{
    grid-column:1!important;
    grid-row:auto!important;
  }
}
    /* Safe UI polish — client search */
    .client-search-wrap{
      margin:12px 0 14px;
      position:relative;
    }
    .client-search-wrap:before{
      content:'⌕';
      position:absolute;
      left:14px;
      top:50%;
      transform:translateY(-50%);
      color:#596600;
      font-weight:900;
      z-index:1;
    }
    #clientSearch{
      padding-left:38px!important;
      background:#fff!important;
      border-radius:16px!important;
      border:1px solid var(--line)!important;
    }
    #clientSearch:focus{
      border-color:#a7bf00!important;
      box-shadow:0 0 0 4px rgba(167,191,0,.12)!important;
      outline:none!important;
    }
    .client-count{
      font-size:12px;
      color:var(--muted);
      margin-top:-4px;
      margin-bottom:10px;
    }


    .client-list-hint{
      font-size:12px;
      color:var(--muted);
      margin-bottom:10px;
    }


    /* FIX — AI Knowledge Box */
    .ai-knowledge-box{
      margin-top:18px;
      padding:18px;
      border-radius:24px;
      background:
        radial-gradient(circle at top right, rgba(167,191,0,.14), transparent 34%),
        linear-gradient(135deg,#fbfcf3,#ffffff);
      border:1px solid var(--line);
      box-shadow:0 14px 36px rgba(44,52,24,.07);
    }
    .ai-knowledge-header{
      display:flex;
      align-items:center;
      gap:12px;
      margin-bottom:10px;
    }
    .ai-knowledge-icon{
      width:38px;
      height:38px;
      border-radius:14px;
      background:#eef1d2;
      display:grid;
      place-items:center;
      font-size:18px;
      flex:0 0 auto;
    }
    .ai-knowledge-title{
      font-size:18px;
      font-weight:950;
      color:#121827;
    }
    .ai-knowledge-sub{
      font-size:13px;
      color:var(--muted);
      margin-bottom:12px;
      line-height:1.5;
    }
    .ai-knowledge-box textarea{
      min-height:150px!important;
      background:rgba(255,255,255,.95)!important;
      border-color:#d9dec3!important;
    }
    .ai-knowledge-tips{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
      margin-top:12px;
    }
    .ai-knowledge-tip{
      padding:7px 10px;
      border-radius:999px;
      background:#eef1d2;
      color:#596600;
      font-size:11px;
      font-weight:900;
    }


    /* Safe UI polish — Meta Connection */
    .meta-card{
      position:relative;
      overflow:hidden;
    }
    .meta-card:before{
      content:'';
      position:absolute;
      inset:auto -60px -80px auto;
      width:180px;
      height:180px;
      border-radius:999px;
      background:rgba(167,191,0,.10);
      pointer-events:none;
    }
    .meta-helper{
      font-size:13px;
      color:var(--muted);
      line-height:1.5;
      margin:8px 0 14px;
    }
    .meta-card #metaStatus{
      display:flex;
      align-items:center;
      gap:12px;
      padding:14px 16px!important;
      border-radius:18px!important;
      font-weight:800;
      font-size:13px;
      margin-bottom:14px;
    }
    .meta-card #metaStatus:before{
      content:'';
      width:10px;
      height:10px;
      border-radius:999px;
      flex:0 0 auto;
      background:#d0d5dd;
      box-shadow:0 0 0 5px rgba(208,213,221,.18);
    }
    .meta-card #metaStatus.ok:before{
      background:#62b053;
      box-shadow:0 0 0 5px rgba(98,176,83,.14);
    }
    .meta-card #metaStatus.warn:before{
      background:#f5a524;
      box-shadow:0 0 0 5px rgba(245,165,36,.14);
    }
    .meta-card #metaStatus.bad:before{
      background:#ff563f;
      box-shadow:0 0 0 5px rgba(255,86,63,.14);
    }
    .meta-actions{
      display:flex;
      gap:10px;
      align-items:center;
      flex-wrap:wrap;
      margin-top:14px;
    }
    .meta-actions button:first-child{
      flex:1;
      min-width:160px;
    }
    .meta-actions .danger{
      background:transparent!important;
      border:1px solid rgba(255,86,63,.24)!important;
      color:#9f1f18!important;
      box-shadow:none!important;
      padding:10px 10px!important;
      font-size:13px!important;
    }
    .meta-sync-card .secondary{
      padding:10px 10px!important;
      font-size:13px!important;
    }
    .meta-sync-helper{
      background:#fbfcf3;
      border:1px solid var(--line);
      border-radius:16px;
      padding:12px;
      color:var(--muted);
      font-size:12px;
      line-height:1.45;
      margin-bottom:14px;
    }


    /* Performance Targets Rebuild */
    .targets-panel{
      margin-top:18px;
      border:1px solid var(--line);
      border-radius:22px;
      background:#fff;
      overflow:hidden;
      box-shadow:0 12px 32px rgba(44,52,24,.05);
    }
    .targets-panel summary{
      list-style:none;
      cursor:pointer;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
      padding:16px 18px;
      user-select:none;
    }
    .targets-panel summary::-webkit-details-marker{display:none}
    .targets-panel summary:after{
      content:'⌄';
      color:#596600;
      font-weight:950;
      font-size:18px;
    }
    .targets-panel[open] summary:after{content:'⌃'}
    .targets-title{
      font-weight:950;
      color:#121827;
      font-size:16px;
    }
    .targets-sub{
      font-size:12px;
      color:var(--muted);
      margin-top:3px;
      font-weight:500;
    }
    .targets-body{
      padding:18px;
      border-top:1px solid #eef1d2;
    }
    .targets-grid{
      display:grid;
      grid-template-columns:repeat(3,minmax(0,1fr));
      gap:12px;
      width:100%;
    }
    .target-field{
      min-width:0;
      width:100%;
    }
    .target-field.full{
      grid-column:span 3;
    }
    .target-field label{
      display:block;
      font-size:12px!important;
      margin:0 0 7px!important;
      color:#1f2937;
      font-weight:800;
      line-height:1.2;
    }
    .target-field input{
      display:block!important;
      width:100%!important;
      max-width:none!important;
      min-width:0!important;
      box-sizing:border-box!important;
      height:46px!important;
      margin:0!important;
    }
    @media(max-width:900px){
      .targets-grid{grid-template-columns:1fr}
      .target-field.full{grid-column:span 1}
    }


    /* Sync Feedback Clean */
    .sync-feedback{
      margin-top:14px;
      border:1px solid #d9dec3;
      background:
        radial-gradient(circle at top right, rgba(167,191,0,.10), transparent 35%),
        #fbfcf3;
      border-radius:20px;
      padding:16px;
      display:flex;
      flex-direction:column;
      gap:10px;
      animation:fadeSyncFeedback .25s ease;
    }
    @keyframes fadeSyncFeedback{
      from{opacity:0;transform:translateY(4px)}
      to{opacity:1;transform:none}
    }
    .sync-feedback-title{
      font-size:15px;
      font-weight:950;
      color:#121827;
      display:flex;
      align-items:center;
      gap:10px;
    }
    .sync-feedback-grid{
      display:grid;
      grid-template-columns:repeat(2,minmax(0,1fr));
      gap:10px;
    }
    .sync-stat{
      background:#fff;
      border:1px solid var(--line);
      border-radius:16px;
      padding:12px;
    }
    .sync-stat-label{
      font-size:11px;
      color:var(--muted);
      margin-bottom:4px;
      text-transform:uppercase;
      letter-spacing:.04em;
      font-weight:800;
    }
    .sync-stat-value{
      font-size:18px;
      font-weight:950;
      color:#121827;
      line-height:1.1;
    }
    .sync-feedback-sub{
      font-size:12px;
      color:var(--muted);
      line-height:1.5;
    }
    @media(max-width:900px){.sync-feedback-grid{grid-template-columns:1fr}}


    /* Sticky Client Actions */
    .sticky-client-actions{
      position:sticky;
      bottom:16px;
      z-index:40;
      margin-top:22px;
      padding:10px;
      border-radius:24px;
      background:rgba(255,255,255,.88);
      backdrop-filter:blur(14px);
      border:1px solid rgba(217,222,195,.9);
      box-shadow:
        0 18px 40px rgba(44,52,24,.10),
        0 2px 10px rgba(44,52,24,.04);
    }
    .sticky-client-actions-inner{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
      flex-wrap:wrap;
    }
    .sticky-client-actions-meta{
      display:flex;
      flex-direction:column;
      gap:3px;
      min-width:180px;
    }
    .sticky-client-actions-title{
      font-size:14px;
      font-weight:950;
      color:#121827;
      line-height:1.1;
    }
    .sticky-client-actions-sub{
      font-size:12px;
      color:var(--muted);
      line-height:1.4;
    }
    .sticky-client-actions-buttons{
      display:flex;
      align-items:center;
      gap:10px;
      flex-wrap:wrap;
    }
    .sticky-client-actions-buttons button{
      min-height:42px!important;
      border-radius:16px!important;
      padding:10px 14px!important;
      font-size:13px!important;
    }
    .sticky-client-actions-buttons .secondary{
      background:#fff!important;
      border:1px solid var(--line)!important;
    }
    .sticky-client-actions-buttons .danger{
      background:transparent!important;
      border:1px solid rgba(255,86,63,.22)!important;
      color:#9f1f18!important;
      box-shadow:none!important;
    }
    @media(max-width:900px){
      .sticky-client-actions-inner{
        flex-direction:column;
        align-items:stretch;
      }
      .sticky-client-actions-buttons{
        width:100%;
      }
      .sticky-client-actions-buttons button{
        flex:1;
      }
    }


.client-list-title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.client-list-title h2{
  margin:0;
}

.client-list-title button{
  white-space:nowrap;
  min-height:36px!important;
  padding:8px 12px!important;
}

.sidebar-client-meta{
  display:grid!important;
  grid-template-columns:1fr 1fr;
  gap:6px!important;
}

.sidebar-client-meta span{
  display:inline-flex!important;
  align-items:center;
  justify-content:center;
  min-height:24px;
  padding:4px 6px!important;
  border-radius:8px!important;
  font-size:10px!important;
  font-weight:900!important;
  background:#f4f4f5!important;
  color:#667085!important;
  white-space:nowrap;
}

.sidebar-client-meta span.ok{
  background:#eef8e9!important;
  color:#2e7d32!important;
}

.sidebar-client-meta span.missing{
  background:#fff7ed!important;
  color:#9a3412!important;
}

.sidebar-client-meta span.disabled{
  background:#f4f4f5!important;
  color:#667085!important;
}

/* Integrations layout */
.client-tab-panel[data-client-tab="integrations"].active{
  display:grid!important;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  gap:18px;
  align-items:start;
}

.integration-col{
  min-width:0;
  display:grid;
  gap:14px;
  align-content:start;
}

.integration-meta{
  grid-column:1;
}

.integration-google{
  grid-column:2;
}

.client-tab-panel[data-client-tab="integrations"] .card{
  margin-top:0!important;
  width:100%!important;
}

.meta-account-card{
  border-color:#cbd89a!important;
  background:linear-gradient(180deg,#fff,#fbfdf2)!important;
}

#view-clients #syncFeedback{
  display:none!important;
}

@media(max-width:900px){
  .client-tab-panel[data-client-tab="integrations"].active{
    grid-template-columns:1fr;
  }
  .integration-meta,
  .integration-google{
    grid-column:1;
  }
}
