/* ── LIGHT MODE (default) ── */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface2: #f0f1f4;
  --border: #e2e4ea;
  --accent: #2563eb;
  --accent2: #e5476b;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #dc2626;
  --text: #1a1d2e;
  --muted: #7c829a;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
}
/* ── DARK MODE ── */
body.dark {
  --bg: #0a0b0e;
  --surface: #13151b;
  --surface2: #1a1d26;
  --border: #252836;
  --accent: #5b8dee;
  --accent2: #ee5b8d;
  --green: #3dd68c;
  --yellow: #f5c842;
  --red: #ee5b5b;
  --text: #e8eaf2;
  --muted: #636880;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}
*{box-sizing:border-box;margin:0;padding:0;}
body{background:var(--bg);color:var(--text);font-family: 'Montserrat', sans-serif;font-size:15px;min-height:100vh;transition:background 0.3s,color 0.3s;}

/* Theme toggle button */
.theme-toggle{
  width:36px;height:36px;border-radius:9px;
  border:1px solid var(--border);background:var(--surface2);
  color:var(--muted);cursor:pointer;font-size:16px;
  display:flex;align-items:center;justify-content:center;
  transition:all 0.15s;flex-shrink:0;
}
.theme-toggle:hover{color:var(--text);border-color:var(--accent);}

/* ── AUTH SCREEN ── */
#auth-screen{
  display:flex;align-items:center;justify-content:center;
  min-height:calc(100vh - 0px);padding:40px 16px;
}
.auth-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:20px;width:420px;max-width:100%;
  box-shadow:var(--shadow);
  overflow:hidden;
}
.auth-header{
  padding:32px 32px 24px;
  background:linear-gradient(135deg,rgba(91,141,238,0.1),rgba(238,91,141,0.05));
  border-bottom:1px solid var(--border);
  text-align:center;
}
.auth-logo{
  font-family:'Montserrat',sans-serif;font-size:28px;font-weight:800;
  letter-spacing:-0.5px;margin-bottom:6px;
}
.auth-logo span{color:var(--accent);}
.auth-subtitle{font-size:13px;color:var(--muted);}
.auth-tabs{display:flex;border-bottom:1px solid var(--border);}
.auth-tab{
  flex:1;padding:14px;text-align:center;cursor:pointer;
  font-size:13px;font-weight:600;color:var(--muted);
  border-bottom:2px solid transparent;transition:all 0.15s;
  margin-bottom:-1px;
}
.auth-tab.active{color:var(--accent);border-bottom-color:var(--accent);}
.auth-body{padding:28px 32px;display:flex;flex-direction:column;gap:16px;}
.form-group{display:flex;flex-direction:column;gap:6px;}
.form-label{font-size:11px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:0.5px;}
.form-input{
  background:var(--surface2);border:1px solid var(--border);
  border-radius:9px;color:var(--text);font-family:'Montserrat',sans-serif;
  font-size:14px;padding:11px 14px;transition:border-color 0.15s;
}
.form-input:focus{outline:none;border-color:var(--accent);}
.form-input::placeholder{color:var(--muted);}
.btn-main{
  width:100%;padding:12px;border-radius:10px;border:none;cursor:pointer;
  font-family:'Montserrat',sans-serif;font-size:15px;font-weight:700;
  background:var(--accent);color:#fff;transition:all 0.2s;margin-top:4px;
  letter-spacing:0.2px;
}
.btn-main:hover{background:#6e9ef0;transform:translateY(-1px);box-shadow:0 8px 24px rgba(91,141,238,0.3);}
.btn-main:disabled{opacity:0.5;cursor:not-allowed;transform:none;}
.auth-divider{text-align:center;font-size:12px;color:var(--muted);}
.auth-error{
  background:rgba(238,91,91,0.1);border:1px solid rgba(238,91,91,0.3);
  border-radius:8px;padding:10px 14px;font-size:13px;color:var(--red);
  display:none;
}
.auth-error.show{display:block;}
.auth-success{
  background:rgba(61,214,140,0.1);border:1px solid rgba(61,214,140,0.3);
  border-radius:8px;padding:10px 14px;font-size:13px;color:var(--green);
  display:none;
}
.auth-success.show{display:block;}

/* ── INVITE SCREEN (after register, no team yet) ── */
#invite-screen{
  display:none;align-items:center;justify-content:center;
  min-height:100vh;padding:40px 16px;
}
.invite-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:20px;width:480px;max-width:100%;padding:36px;
  box-shadow:0 24px 64px rgba(0,0,0,0.5);text-align:center;
}
.invite-icon{font-size:48px;margin-bottom:16px;}
.invite-title{font-family:'Montserrat',sans-serif;font-size:22px;font-weight:800;margin-bottom:8px;}
.invite-sub{font-size:14px;color:var(--muted);line-height:1.6;margin-bottom:24px;}
.invite-options{display:flex;flex-direction:column;gap:12px;}
.invite-option{
  background:var(--surface2);border:1px solid var(--border);border-radius:12px;
  padding:18px;cursor:pointer;transition:all 0.15s;text-align:left;
  display:flex;align-items:center;gap:14px;
}
.invite-option:hover{border-color:var(--accent);background:rgba(91,141,238,0.05);}
.invite-option-icon{font-size:24px;flex-shrink:0;}
.invite-option-title{font-weight:600;font-size:15px;margin-bottom:2px;}
.invite-option-sub{font-size:12px;color:var(--muted);}

/* ── CREATE TEAM FLOW ── */
#create-team-screen{
  display:none;align-items:center;justify-content:center;
  min-height:100vh;padding:40px 16px;
}

/* ── ENTER INVITE CODE ── */
#enter-code-screen{
  display:none;align-items:center;justify-content:center;
  min-height:100vh;padding:40px 16px;
}

/* ── MAIN APP ── */
#app{display:none;}
.layout{
  display:flex;
  height:100vh;
  height:100dvh; /* dynamic viewport height - fixes iOS Safari */
  overflow:hidden;
}

/* SIDEBAR */
.sidebar{
  width:220px;min-width:220px;background:var(--surface);
  border-right:1px solid var(--border);
  display:flex;flex-direction:column;padding:20px 0;
}
.logo{
  font-family:'Montserrat',sans-serif;font-weight:800;font-size:20px;
  padding:0 18px 20px;display:flex;align-items:center;gap:8px;
}
.logo span{color:var(--accent);}
.logo-dot{width:7px;height:7px;border-radius:50%;background:var(--accent);box-shadow:0 0 8px var(--accent);animation:pulse 2s infinite;}
@keyframes pulse{0%,100%{opacity:1;}50%{opacity:0.3;}}
.team-badge{
  margin:0 14px 16px;background:var(--surface2);border:1px solid var(--border);
  border-radius:10px;padding:10px 12px;
}
.team-name{font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.team-role{font-size:11px;color:var(--muted);margin-top:2px;}
.nav-label{font-size:10px;text-transform:uppercase;letter-spacing:1.5px;color:var(--muted);padding:10px 18px 4px;font-weight:600;}
.nav-item{
  display:flex;align-items:center;gap:9px;padding:9px 18px;
  cursor:pointer;color:var(--muted);transition:all 0.15s;font-size:14px;
  border-left:3px solid transparent;
}
.nav-item:hover{color:var(--text);background:var(--surface2);}
.nav-item.active{color:var(--text);background:var(--surface2);border-left-color:var(--accent);}
.nav-item svg{width:15px;height:15px;flex-shrink:0;}
.sidebar-footer{
  margin-top:auto;padding:14px;
  border-top:1px solid var(--border);
}
.user-row{display:flex;align-items:center;gap:10px;}
.user-avatar{
  width:34px;height:34px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  font-size:12px;font-weight:700;flex-shrink:0;
  background:rgba(91,141,238,0.2);color:var(--accent);
}
.user-info{flex:1;min-width:0;}
.user-name{font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.user-email{font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.btn-logout{
  background:none;border:none;color:var(--muted);cursor:pointer;
  font-size:18px;padding:4px;transition:color 0.15s;
}
.btn-logout:hover{color:var(--red);}

/* MAIN */
.main{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0;}
.topbar{
  height:58px;border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;
  padding:0 24px;background:var(--surface);flex-shrink:0;
}
.topbar-title{font-family:'Montserrat',sans-serif;font-size:17px;font-weight:700;}
.topbar-actions{display:flex;gap:8px;align-items:center;}
.btn{
  padding:7px 14px;border-radius:8px;border:none;cursor:pointer;
  font-family:'Montserrat',sans-serif;font-size:13px;font-weight:500;
  transition:all 0.15s;display:flex;align-items:center;gap:6px;
}
.btn-primary{background:var(--accent);color:#fff;}
.btn-primary:hover{background:#6e9ef0;transform:translateY(-1px);}
.btn-ghost{background:var(--surface2);color:var(--text);border:1px solid var(--border);}
.btn-ghost:hover{background:var(--border);}
.btn-danger{background:rgba(238,91,91,0.15);color:var(--red);border:1px solid rgba(238,91,91,0.3);}
.btn-danger:hover{background:rgba(238,91,91,0.25);}

/* VIEWS */
.view{display:none;flex:1;overflow:auto;padding:24px;flex-direction:column;gap:20px;}
.view.active{display:flex;}

/* KANBAN */
.kanban-board{display:flex;gap:16px;align-items:flex-start;min-height:400px;overflow-x:auto;padding-bottom:8px;}
.kanban-col{min-width:270px;max-width:270px;background:var(--surface);border-radius:var(--radius);border:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden;}
.col-header{display:flex;align-items:center;justify-content:space-between;padding:13px 14px;border-bottom:1px solid var(--border);}
.col-title-row{display:flex;align-items:center;gap:7px;}
.col-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0;}
.col-title{font-family:'Montserrat',sans-serif;font-size:12px;font-weight:700;letter-spacing:0.3px;}
.col-count{background:var(--surface2);color:var(--muted);font-size:11px;padding:2px 7px;border-radius:20px;font-weight:500;}
.col-add{width:24px;height:24px;border-radius:6px;border:1px solid var(--border);background:transparent;color:var(--muted);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:16px;transition:all 0.15s;}
.col-add:hover{background:var(--surface2);color:var(--text);}
.col-cards{padding:10px;display:flex;flex-direction:column;gap:8px;min-height:50px;}
.card{
  background:var(--surface2);border-radius:10px;border:1px solid var(--border);
  padding:13px;cursor:pointer;transition:all 0.15s;position:relative;overflow:hidden;
}
.card::before{content:'';position:absolute;left:0;top:0;bottom:0;width:3px;}
.card.p-alta::before{background:var(--red);}
.card.p-media::before{background:var(--yellow);}
.card.p-baja::before{background:var(--green);}
.card:hover{border-color:var(--accent);transform:translateY(-2px);box-shadow:0 6px 20px rgba(0,0,0,0.3);}
.card-title{font-size:13px;font-weight:500;margin-bottom:8px;line-height:1.4;}
.card-meta{display:flex;align-items:center;gap:6px;flex-wrap:wrap;}
.badge{font-size:10px;padding:2px 7px;border-radius:20px;font-weight:600;text-transform:uppercase;letter-spacing:0.4px;}
.b-alta{background:rgba(238,91,91,0.12);color:var(--red);}
.b-media{background:rgba(245,200,66,0.12);color:var(--yellow);}
.b-baja{background:rgba(61,214,140,0.12);color:var(--green);}
.card-date{font-size:11px;color:var(--muted);margin-left:auto;}
.card-date.over{color:var(--red);}
.assignee-chip{
  width:22px;height:22px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  font-size:9px;font-weight:700;flex-shrink:0;
}
.cl-bar{height:3px;background:var(--border);border-radius:2px;overflow:hidden;margin-top:8px;}
.cl-fill{height:100%;background:var(--green);border-radius:2px;}

/* LIST */
.list-table{width:100%;border-collapse:collapse;}
.list-table th{text-align:left;padding:10px 14px;font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--muted);font-weight:600;border-bottom:1px solid var(--border);}
.list-table td{padding:11px 14px;border-bottom:1px solid var(--border);vertical-align:middle;font-size:13px;}
.list-table tr:hover td{background:var(--surface2);cursor:pointer;}
.status-pill{display:inline-flex;align-items:center;gap:5px;font-size:11px;padding:3px 9px;border-radius:20px;font-weight:500;}
.s-todo{background:rgba(99,104,128,0.2);color:var(--muted);}
.s-progress{background:rgba(91,141,238,0.15);color:var(--accent);}
.s-review{background:rgba(245,200,66,0.15);color:var(--yellow);}
.s-done{background:rgba(61,214,140,0.15);color:var(--green);}
.s-dot{width:5px;height:5px;border-radius:50%;background:currentColor;}

/* STATS */
.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;}
.stat-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:18px;}
.stat-label{font-size:11px;color:var(--muted);margin-bottom:6px;font-weight:500;}
.stat-value{font-family:'Montserrat',sans-serif;font-size:30px;font-weight:800;}

/* ADMIN PANEL */
.admin-section{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px;}
.admin-section-title{font-family:'Montserrat',sans-serif;font-size:15px;font-weight:700;margin-bottom:16px;display:flex;align-items:center;gap:8px;}
.member-row{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid var(--border);}
.member-row:last-child{border-bottom:none;}
.member-info{flex:1;}
.member-name-txt{font-size:14px;font-weight:500;}
.member-email-txt{font-size:12px;color:var(--muted);}
.role-badge{font-size:11px;padding:3px 10px;border-radius:20px;font-weight:600;}
.role-admin{background:rgba(91,141,238,0.15);color:var(--accent);}
.role-member{background:rgba(99,104,128,0.15);color:var(--muted);}
.invite-box{display:flex;gap:10px;margin-top:4px;}
.invite-input{flex:1;background:var(--surface2);border:1px solid var(--border);border-radius:9px;color:var(--text);font-family:'Montserrat',sans-serif;font-size:14px;padding:10px 14px;}
.invite-input:focus{outline:none;border-color:var(--accent);}
.code-display{
  background:var(--surface2);border:1px dashed var(--border);border-radius:10px;
  padding:14px 18px;font-family:monospace;font-size:18px;letter-spacing:4px;
  text-align:center;color:var(--accent);font-weight:700;cursor:pointer;
  transition:all 0.15s;margin-top:8px;
}
.code-display:hover{border-color:var(--accent);}
.code-hint{font-size:12px;color:var(--muted);text-align:center;margin-top:6px;}

/* MODAL */
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:100;align-items:center;justify-content:center;backdrop-filter:blur(4px);}
.modal-overlay.open{display:flex;}
.modal{background:var(--surface);border:1px solid var(--border);border-radius:16px;width:500px;max-width:95vw;max-height:90vh;overflow-y:auto;box-shadow:0 24px 64px rgba(0,0,0,0.5);animation:mIn 0.2s ease;}
@keyframes mIn{from{opacity:0;transform:translateY(12px) scale(0.98);}to{opacity:1;transform:none;}}
.modal-header{display:flex;align-items:center;justify-content:space-between;padding:18px 22px 14px;border-bottom:1px solid var(--border);}
.modal-title{font-family:'Montserrat',sans-serif;font-size:16px;font-weight:700;}
.modal-close{width:28px;height:28px;border-radius:7px;border:1px solid var(--border);background:transparent;color:var(--muted);cursor:pointer;font-size:15px;display:flex;align-items:center;justify-content:center;transition:all 0.15s;}
.modal-close:hover{background:var(--surface2);color:var(--text);}
.modal-body{padding:18px 22px;display:flex;flex-direction:column;gap:14px;}
.modal-footer{padding:14px 22px 18px;display:flex;justify-content:flex-end;gap:8px;border-top:1px solid var(--border);}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:10px;}
.form-select{background:var(--surface2);border:1px solid var(--border);border-radius:9px;color:var(--text);font-family:'Montserrat',sans-serif;font-size:14px;padding:10px 12px;width:100%;}
.form-select:focus{outline:none;border-color:var(--accent);}
.form-textarea{background:var(--surface2);border:1px solid var(--border);border-radius:9px;color:var(--text);font-family:'Montserrat',sans-serif;font-size:14px;padding:10px 12px;width:100%;resize:vertical;min-height:70px;}
.form-textarea:focus{outline:none;border-color:var(--accent);}
.cl-list{display:flex;flex-direction:column;gap:7px;}
.cl-item{display:flex;align-items:center;gap:9px;background:var(--surface2);border-radius:8px;padding:8px 11px;}
.cl-item input[type=checkbox]{accent-color:var(--accent);width:14px;height:14px;}
.cl-item label{font-size:13px;cursor:pointer;flex:1;}
.cl-item label.done{text-decoration:line-through;color:var(--muted);}
.comments-list{display:flex;flex-direction:column;gap:8px;}
.comment{display:flex;gap:9px;align-items:flex-start;}
.comment-bubble{background:var(--surface2);border-radius:9px;padding:9px 13px;flex:1;}
.comment-author{font-size:11px;font-weight:700;color:var(--accent);margin-bottom:3px;}
.comment-text{font-size:13px;}
.comment-time{font-size:10px;color:var(--muted);margin-top:3px;}
.comment-input-row{display:flex;gap:8px;align-items:center;}
.comment-input{flex:1;background:var(--surface2);border:1px solid var(--border);border-radius:8px;color:var(--text);font-family:'Montserrat',sans-serif;font-size:13px;padding:8px 12px;}
.comment-input:focus{outline:none;border-color:var(--accent);}

/* NOTIF */
.notif{display:none;position:fixed;bottom:22px;right:22px;background:var(--surface2);border:1px solid var(--border);border-left:3px solid var(--accent);border-radius:11px;padding:13px 16px;font-size:13px;z-index:200;max-width:280px;box-shadow:0 8px 32px rgba(0,0,0,0.4);animation:nIn 0.3s ease;}
@keyframes nIn{from{opacity:0;transform:translateX(16px);}to{opacity:1;transform:none;}}
.notif.show{display:block;}
.notif-title{font-weight:600;margin-bottom:2px;}
.notif-sub{font-size:11px;color:var(--muted);}

/* DRAG */
.drag-over{background:rgba(91,141,238,0.07)!important;border:1px dashed var(--accent)!important;}

/* LOADING */
.loading{display:flex;align-items:center;justify-content:center;height:100vh;flex-direction:column;gap:16px;}
.spinner{width:36px;height:36px;border:3px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin 0.8s linear infinite;}
@keyframes spin{to{transform:rotate(360deg);}}

/* ── FILE UPLOAD ── */
.upload-zone{
  border:2px dashed var(--border);border-radius:10px;
  padding:18px;text-align:center;cursor:pointer;
  transition:all 0.2s;background:var(--surface2);
  position:relative;
}
.upload-zone:hover,.upload-zone.dragover{
  border-color:var(--accent);background:rgba(91,141,238,0.05);
}
.upload-zone input[type=file]{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%;}
.upload-icon{font-size:24px;margin-bottom:6px;}
.upload-hint{font-size:12px;color:var(--muted);line-height:1.5;}
.upload-hint strong{color:var(--text);}
.file-list{display:flex;flex-direction:column;gap:7px;margin-top:8px;}
.file-item{
  display:flex;align-items:center;gap:10px;
  background:var(--surface2);border:1px solid var(--border);
  border-radius:9px;padding:9px 12px;
  transition:all 0.15s;
}
.file-item:hover{border-color:var(--accent);}
.file-icon{font-size:20px;flex-shrink:0;}
.file-info{flex:1;min-width:0;}
.file-name{font-size:13px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.file-meta{font-size:11px;color:var(--muted);margin-top:1px;}
.file-actions{display:flex;gap:6px;flex-shrink:0;}
.file-btn{
  padding:4px 10px;border-radius:6px;border:1px solid var(--border);
  background:transparent;color:var(--muted);cursor:pointer;font-size:11px;
  font-family:'Montserrat',sans-serif;transition:all 0.15s;
}
.file-btn:hover{background:var(--surface);color:var(--text);}
.file-btn.del:hover{border-color:var(--red);color:var(--red);background:rgba(238,91,91,0.08);}
.upload-progress{
  height:3px;background:var(--border);border-radius:2px;
  overflow:hidden;margin-top:6px;
}
.upload-progress-bar{height:100%;background:var(--accent);border-radius:2px;transition:width 0.3s;}
.card-attachments{
  display:flex;gap:4px;margin-top:7px;flex-wrap:wrap;
}
.card-attach-chip{
  font-size:10px;padding:2px 7px;border-radius:5px;
  background:rgba(91,141,238,0.1);color:var(--accent);
  display:flex;align-items:center;gap:3px;
}

::-webkit-scrollbar{width:5px;height:5px;}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px;}

/* ── MOBILE TEAM BAR ── */
#mobile-team-bar{
  display:none;
  align-items:center;gap:8px;
  padding:8px 16px;
  background:var(--surface2);
  border-bottom:1px solid var(--border);
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
#mobile-team-bar:active{background:var(--border);}
.mtb-team-name{
  font-size:13px;font-weight:700;color:var(--text);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:180px;
}
.mtb-role{
  font-size:11px;color:var(--muted);
  background:var(--surface);border:1px solid var(--border);
  border-radius:20px;padding:1px 8px;white-space:nowrap;flex-shrink:0;
}

/* ── BOTTOM NAV ── */
.bottom-nav{
  display:none;
  position:fixed;bottom:0;left:0;right:0;
  background:var(--surface);
  border-top:1px solid var(--border);
  padding:6px 8px max(10px, env(safe-area-inset-bottom));
  z-index:100;
  box-shadow:0 -4px 20px rgba(0,0,0,0.06);
}
.bottom-nav-inner{
  display:flex;justify-content:space-around;align-items:center;
  max-width:500px;margin:0 auto;
}
.bn-item{
  display:flex;flex-direction:column;align-items:center;gap:4px;
  padding:6px 12px;cursor:pointer;color:var(--muted);
  font-size:10px;font-weight:600;letter-spacing:0.2px;
  border-radius:12px;transition:all 0.15s;min-width:52px;
  -webkit-tap-highlight-color:transparent;
  position:relative;
}
.bn-item svg{width:22px;height:22px;transition:transform 0.15s;}
.bn-item.active{color:var(--accent);}
.bn-item.active svg{transform:scale(1.1);}
.bn-item.active::before{
  content:'';position:absolute;top:0;left:50%;transform:translateX(-50%);
  width:24px;height:3px;border-radius:0 0 3px 3px;
  background:var(--accent);
}
.bn-fab{
  width:52px;height:52px;border-radius:50%;
  background:var(--accent);color:#fff;border:none;
  font-size:26px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 4px 16px rgba(0,0,0,0.2);
  transition:all 0.15s;margin-top:-18px;
  -webkit-tap-highlight-color:transparent;
  flex-shrink:0;
}
.bn-fab:active{transform:scale(0.92);}
/* hide labels on very small screens */
@media (max-width: 360px) { .bn-item{font-size:9px;min-width:44px;padding:6px 8px;} }

/* ── DRAG FEEDBACK ── */
.card[draggable="true"]{cursor:grab;transition:opacity 0.15s,box-shadow 0.15s;}
.col-cards.drag-over{
  background:rgba(37,99,235,0.06);
  border-radius:10px;
  outline:2px dashed var(--accent);
  outline-offset:-2px;
  min-height:60px;
}

/* ── CALENDAR ── */
.cal-day{
  min-height:100px;padding:8px;
  background:var(--surface);
  transition:background 0.1s;
  cursor:pointer;
}
.cal-day:hover{background:var(--surface2);}
.cal-day.today .cal-day-num{
  background:var(--accent);color:#fff;
  border-radius:50%;width:24px;height:24px;
  display:flex;align-items:center;justify-content:center;font-size:12px;
}
.cal-day.cur-month{background:var(--surface);}
.cal-day:not(.cur-month){background:var(--surface2);opacity:0.5;}
.cal-day-num{font-size:13px;font-weight:600;margin-bottom:4px;}
.cal-day-name{
  text-align:center;font-size:11px;font-weight:700;
  text-transform:uppercase;letter-spacing:0.5px;
  color:var(--muted);padding:10px 4px;
  background:var(--surface2);
}
.cal-event{
  font-size:11px;font-weight:500;
  padding:2px 6px;border-radius:4px;
  margin-bottom:2px;white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;
  cursor:pointer;
}
.cal-event:hover{opacity:0.8;}
.cal-more{font-size:10px;color:var(--muted);padding:1px 4px;}

/* Upcoming events */
.upcoming-event{
  display:flex;align-items:flex-start;gap:12px;
  padding:10px 0;border-bottom:1px solid var(--border);
}
.upcoming-event:last-child{border-bottom:none;}
.upcoming-dot{
  width:10px;height:10px;border-radius:50%;
  flex-shrink:0;margin-top:4px;
}
.upcoming-title{font-size:13px;font-weight:500;}
.upcoming-time{font-size:11px;color:var(--muted);margin-top:2px;}

/* ── SWEETALERT2 ── */
.dugout-toast{border-radius:12px!important;box-shadow:0 8px 32px rgba(0,0,0,0.18)!important;border:1px solid var(--border)!important;font-family:'Montserrat',sans-serif!important;}
.dugout-dialog{border-radius:20px!important;font-family:'Montserrat',sans-serif!important;border:1px solid var(--border)!important;}
.swal2-title{font-family:'Montserrat',sans-serif!important;font-size:18px!important;}
.swal2-confirm,.swal2-cancel{border-radius:10px!important;font-family:'Montserrat',sans-serif!important;font-weight:600!important;padding:10px 22px!important;}
.swal2-timer-progress-bar{background:var(--accent)!important;}
.swal2-input{border-radius:10px!important;border:1px solid var(--border)!important;font-family:'Montserrat',sans-serif!important;font-size:14px!important;background:var(--surface2)!important;color:var(--text)!important;box-shadow:none!important;}
.swal2-input:focus{border-color:var(--accent)!important;outline:none!important;}
.dark .dugout-toast,.dark .dugout-dialog{background:#1e1e2e!important;color:#e2e8f0!important;}

/* ── GANTT / BOARD VIEW ── */
.board-selector{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:4px;}
.board-tab{padding:7px 16px;border-radius:8px;border:1px solid var(--border);background:var(--surface2);font-size:13px;font-weight:500;cursor:pointer;transition:all 0.15s;color:var(--muted);}
.board-tab:hover{color:var(--text);border-color:var(--accent);}
.board-tab.active{background:var(--accent);color:#fff;border-color:var(--accent);}
.board-tab-add{padding:7px 12px;border-radius:8px;border:1px dashed var(--border);background:transparent;font-size:13px;cursor:pointer;color:var(--muted);transition:all 0.15s;}
.board-tab-add:hover{border-color:var(--accent);color:var(--accent);}
.view-toggle{display:flex;background:var(--surface2);border:1px solid var(--border);border-radius:8px;overflow:hidden;}
.view-toggle-btn{padding:6px 14px;font-size:12px;font-weight:600;cursor:pointer;color:var(--muted);transition:all 0.15s;border:none;background:transparent;font-family:'Montserrat',sans-serif;}
.view-toggle-btn.active{background:var(--accent);color:#fff;}
.board-table-wrap{overflow:auto;border:1px solid var(--border);border-radius:var(--radius);}
.board-table{border-collapse:collapse;min-width:100%;font-size:13px;}
.board-table th{background:var(--surface2);padding:9px 12px;text-align:left;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:0.8px;color:var(--muted);border-bottom:1px solid var(--border);white-space:nowrap;position:sticky;top:0;z-index:2;}
.board-table th.col-name{min-width:220px;left:0;z-index:3;background:var(--surface2);}
.board-table td{padding:0;border-bottom:1px solid var(--border);vertical-align:middle;white-space:nowrap;}
.board-table td.col-name{position:sticky;left:0;background:var(--surface);z-index:1;min-width:220px;}
.board-table tr:hover td{background:var(--surface2);}
.board-table tr:hover td.col-name{background:var(--surface2);}
.group-header-row td{background:var(--surface)!important;padding:0;}
.group-header{display:flex;align-items:center;gap:8px;padding:8px 12px;font-weight:700;font-size:13px;cursor:pointer;border-left:4px solid var(--group-color,#5b8dee);}
.group-chevron{font-size:10px;transition:transform 0.2s;display:inline-block;}
.group-chevron.collapsed{transform:rotate(-90deg);}
.group-actions{margin-left:auto;display:flex;gap:4px;opacity:0;transition:opacity 0.15s;}
.group-header:hover .group-actions{opacity:1;}
.group-action-btn{padding:2px 8px;border-radius:5px;border:1px solid var(--border);background:var(--surface2);font-size:11px;cursor:pointer;color:var(--muted);transition:all 0.15s;}
.group-action-btn:hover{color:var(--text);border-color:var(--accent);}
.item-row td.col-name .item-indent{padding-left:24px;display:flex;align-items:center;gap:6px;}
.subitem-row td.col-name .item-indent{padding-left:48px;}
.item-expand{width:16px;height:16px;display:flex;align-items:center;justify-content:center;font-size:10px;cursor:pointer;color:var(--muted);flex-shrink:0;}
.item-name-input{border:none;background:transparent;color:var(--text);font-size:13px;font-family:'Montserrat',sans-serif;width:100%;padding:9px 4px;outline:none;cursor:pointer;}
.item-name-input:focus{cursor:text;background:var(--surface2);}
.add-item-row td{padding:0;}
.add-item-btn{display:flex;align-items:center;gap:6px;padding:7px 12px 7px 28px;font-size:12px;color:var(--muted);cursor:pointer;transition:color 0.15s;border:none;background:transparent;font-family:'Montserrat',sans-serif;width:100%;border-left:4px solid transparent;}
.add-item-btn:hover{color:var(--accent);}
.add-subitem-btn{padding-left:52px;}
.cell-wrap{padding:8px 10px;display:flex;align-items:center;min-height:36px;cursor:pointer;}
.cell-wrap:hover{background:rgba(37,99,235,0.06);}
.status-cell{display:inline-flex;align-items:center;padding:3px 10px;border-radius:6px;font-size:12px;font-weight:600;cursor:pointer;}
.priority-cell{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:600;}
.person-cell{display:flex;align-items:center;gap:5px;}
.date-cell-input{border:none;background:transparent;color:var(--text);font-size:12px;font-family:'Montserrat',sans-serif;cursor:pointer;padding:0;width:110px;}
.date-cell-input:focus{outline:none;}
.number-cell-input{border:none;background:transparent;color:var(--text);font-size:12px;font-family:'Montserrat',sans-serif;text-align:right;width:80px;padding:0;}
.number-cell-input:focus{outline:none;background:var(--surface2);border-radius:4px;}
.text-cell-input{border:none;background:transparent;color:var(--text);font-size:12px;font-family:'Montserrat',sans-serif;width:120px;padding:0;}
.text-cell-input:focus{outline:none;}
.checkbox-cell{display:flex;align-items:center;justify-content:center;}
.checkbox-cell input{accent-color:var(--accent);width:15px;height:15px;cursor:pointer;}
.timeline-cell{display:flex;align-items:center;gap:4px;font-size:11px;color:var(--muted);}
.timeline-bar{height:8px;border-radius:4px;background:var(--accent);opacity:0.7;min-width:4px;}
.add-col-th{width:44px;text-align:center!important;cursor:pointer;color:var(--muted)!important;}
.add-col-th:hover{color:var(--accent)!important;}
.group-tag{display:inline-flex;align-items:center;gap:4px;font-size:10px;padding:1px 7px;border-radius:10px;font-weight:600;margin-left:4px;}
.col-type-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:4px;}
.col-type-option{padding:12px 10px;border-radius:10px;border:1px solid var(--border);background:var(--surface2);cursor:pointer;text-align:center;transition:all 0.15s;}
.col-type-option:hover,.col-type-option.selected{border-color:var(--accent);background:rgba(37,99,235,0.07);}
.col-type-icon{font-size:20px;margin-bottom:4px;}
.col-type-label{font-size:11px;font-weight:600;color:var(--muted);}
.gantt-wrap{overflow:auto;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);}
.gantt-container{display:flex;flex-direction:column;}
.gantt-row{display:flex;border-bottom:1px solid var(--border);min-height:36px;}
.gantt-row:hover{background:var(--surface2);}
.gantt-row-label{min-width:220px;max-width:220px;padding:8px 12px;font-size:13px;display:flex;align-items:center;gap:6px;border-right:1px solid var(--border);flex-shrink:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.gantt-row-label.subitem{padding-left:32px;font-size:12px;color:var(--muted);}
.gantt-row-label.group-label{font-weight:700;font-size:12px;}
.gantt-header-left{min-width:220px;max-width:220px;padding:9px 12px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:0.8px;color:var(--muted);border-right:1px solid var(--border);flex-shrink:0;}
.gantt-month{text-align:center;font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:0.5px;padding:9px 0;border-right:1px solid var(--border);flex-shrink:0;}
.gantt-day-cell{width:28px;min-width:28px;text-align:center;font-size:10px;color:var(--muted);padding:4px 0;border-right:1px solid var(--border);flex-shrink:0;}
.gantt-day-cell.today{background:rgba(37,99,235,0.1);color:var(--accent);font-weight:700;}
.gantt-day-cell.weekend{background:rgba(0,0,0,0.03);}
.gantt-cell{width:28px;min-width:28px;border-right:1px solid var(--border);flex-shrink:0;}
.gantt-cell.today{background:rgba(37,99,235,0.05);}
.gantt-cell.weekend{background:rgba(0,0,0,0.02);}
.gantt-bar{height:22px;border-radius:6px;cursor:pointer;display:flex;align-items:center;padding:0 8px;font-size:11px;font-weight:600;color:#fff;white-space:nowrap;overflow:hidden;transition:opacity 0.15s;position:relative;min-width:4px;pointer-events:all;}
.gantt-bar:hover{opacity:0.85;}

/* ── PROFILE ── */
.profile-tab{padding:8px 20px;font-size:13px;font-weight:600;cursor:pointer;display:flex;align-items:center;gap:7px;white-space:nowrap;border-radius:9px;transition:all 0.15s;}
.notif-pref-row{display:flex;align-items:center;gap:14px;background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:14px 16px;cursor:pointer;transition:all 0.15s;}
.notif-pref-row:hover{border-color:var(--accent);}
.notif-check{accent-color:var(--accent);width:18px;height:18px;flex-shrink:0;cursor:pointer;}
.notif-pref-info{flex:1;}
.notif-pref-title{font-size:14px;font-weight:600;margin-bottom:2px;}
.notif-pref-sub{font-size:12px;color:var(--muted);}
#profile-avatar-upload:hover #avatar-hover{display:flex!important;}

/* ── MOBILE ── */
@media (max-width: 768px) {
  .sidebar{display:none!important;}
  .bottom-nav{display:flex!important;}
  #mobile-team-bar{display:flex!important;}
  .layout{flex-direction:column;}
  .main{height:100vh;padding-bottom:74px;overflow:hidden;}
  .topbar{padding:0 14px;height:52px;}
  .topbar-title{font-size:15px;}
  .topbar-actions .btn span{display:none;}
  .topbar-actions .btn{padding:7px 10px;}
  .view{padding:12px;gap:12px;overflow-y:auto;overflow-x:hidden;}
  .stats-grid{grid-template-columns:1fr 1fr;gap:8px;}
  .stat-value{font-size:22px;}
  #view-dashboard>div:last-child{grid-template-columns:1fr!important;}

  /* ── KANBAN: full-height swipeable columns, no nested scroll conflict ── */
  #view-kanban.active{padding:0;gap:0;overflow:hidden;flex-direction:column;}
  #kanban-filters{flex-shrink:0;padding:8px 12px;overflow-x:auto;flex-wrap:nowrap!important;scrollbar-width:none;-webkit-overflow-scrolling:touch;border-bottom:1px solid var(--border);}
  #kanban-filters::-webkit-scrollbar{display:none;}
  .kanban-board{flex:1;overflow-x:scroll;overflow-y:hidden;flex-wrap:nowrap!important;-webkit-overflow-scrolling:touch;scroll-snap-type:x mandatory;scroll-behavior:smooth;padding:12px;gap:12px;align-items:stretch;}
  .kanban-col{min-width:calc(100vw - 48px)!important;max-width:calc(100vw - 48px)!important;flex-shrink:0;scroll-snap-align:start;overflow-y:auto;height:100%;}

  /* ── GANTT: full-height scrollable views ── */
  #view-gantt.active{padding:0;gap:0;overflow:hidden;flex-direction:column;}
  #view-gantt > div:first-child{flex-direction:column!important;align-items:stretch!important;gap:8px!important;padding:12px;flex-shrink:0;}
  #view-gantt > div:first-child > div:last-child{display:flex;justify-content:space-between;align-items:center;}
  #board-table-view,#board-gantt-view{flex:1;overflow:auto;-webkit-overflow-scrolling:touch;}
  .board-table-wrap{overflow-x:auto;min-height:100%;}
  .gantt-wrap{overflow:auto;min-height:100%;}
  .view-toggle-btn{padding:6px 10px;font-size:11px;}
  .board-table th,.board-table td{white-space:nowrap;}
  /* Disable sticky columns/headers on mobile — whole table scrolls freely */
  .board-table th{position:static!important;}
  .board-table th.col-name{position:static!important;left:auto!important;min-width:140px;}
  .board-table td.col-name{position:static!important;left:auto!important;min-width:140px;}
  .board-selector{overflow-x:auto;flex-wrap:nowrap!important;scrollbar-width:none;max-width:100%;}
  .board-selector::-webkit-scrollbar{display:none;}
  .board-tab{flex-shrink:0;padding:6px 12px;font-size:12px;}
  .board-tab-add{padding:6px 10px;font-size:12px;}
  .gantt-row-label,.gantt-header-left{min-width:130px;max-width:130px;font-size:11px;}

  /* ── TEAM SWITCHER: fixed below mobile team bar ── */
  #team-switcher-dropdown{position:fixed!important;top:88px!important;left:12px!important;right:12px!important;width:auto!important;border-radius:12px!important;z-index:9999!important;box-shadow:0 8px 32px rgba(0,0,0,0.18)!important;max-height:60vh;overflow-y:auto;}

  #list-filters{overflow-x:auto;flex-wrap:nowrap!important;scrollbar-width:none;-webkit-overflow-scrolling:touch;}
  #list-filters::-webkit-scrollbar{display:none;}
  #view-list{padding:12px 0;}
  .list-table th:nth-child(5),.list-table td:nth-child(5){display:none;}
  .cal-day{min-height:60px;padding:4px;}
  .cal-day-name{padding:8px 2px;font-size:9px;}
  .cal-event{font-size:10px;}
  .modal-overlay{align-items:flex-end!important;}
  .modal{width:100%!important;max-width:100%!important;margin:0!important;border-radius:20px 20px 0 0!important;max-height:90vh;overflow-y:auto;}
  .form-row{display:flex!important;flex-direction:column!important;gap:10px;}
  .form-input,.form-select{font-size:16px!important;}
  .admin-section{padding:12px!important;}
  .notif{bottom:78px;right:14px;left:14px;max-width:none;}
  .auth-card{border-radius:16px;}
}

@media (max-width: 400px) {
  .kanban-col{min-width:calc(100vw - 32px)!important;max-width:calc(100vw - 32px)!important;}
  .topbar-title{font-size:14px;}
}

/* ── NOTIFICATION BELL ── */
.notif-bell {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.notif-bell:hover { color: var(--text); background: var(--surface2); }
.notif-badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── SEARCH RESULT ITEM ── */
.search-result-item:hover { background: var(--surface2) !important; }

/* ── REPORTS ── */
#view-reports .stat-card { padding: 14px 18px; }

/* ── UPDATES SYSTEM ── */
.update-tool-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; padding: 4px 6px; border-radius: 6px;
  transition: background 0.15s; color: var(--muted);
}
.update-tool-btn:hover { background: var(--border); }

#update-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted); pointer-events: none;
}
#update-edit-editor:empty::before {
  content: 'Edita tu actualización...';
  color: var(--muted); pointer-events: none;
}

.update-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  position: relative;
  transition: border-color 0.15s;
}
.update-card.pinned {
  border-color: var(--accent);
  background: rgba(37,99,235,0.03);
}
.update-card:hover .update-actions { opacity: 1; }

.update-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.update-author-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.update-author-name { font-size: 13px; font-weight: 700; }
.update-time { font-size: 11px; color: var(--muted); margin-left: 4px; }
.update-edited { font-size: 10px; color: var(--muted); font-style: italic; }
.update-pin-badge {
  font-size: 10px; color: var(--accent); font-weight: 700;
  background: rgba(37,99,235,0.1); padding: 1px 7px; border-radius: 8px;
  margin-left: 4px;
}

.update-actions {
  position: absolute; top: 10px; right: 12px;
  display: flex; gap: 4px; opacity: 0;
  transition: opacity 0.15s;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 4px;
}
.update-action-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; padding: 3px 6px; border-radius: 5px;
  color: var(--muted); transition: all 0.15s;
}
.update-action-btn:hover { background: var(--surface2); color: var(--text); }

.update-content {
  font-size: 13px; line-height: 1.7; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.update-content .mention {
  color: var(--accent); font-weight: 600;
  background: rgba(37,99,235,0.1);
  padding: 0 4px; border-radius: 4px;
  cursor: pointer;
}

.update-images {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.update-img {
  max-width: 200px; max-height: 160px;
  border-radius: 8px; object-fit: cover;
  cursor: pointer; transition: opacity 0.15s;
  border: 1px solid var(--border);
}
.update-img:hover { opacity: 0.85; }

.update-file-attach {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: 12px; cursor: pointer; margin-top: 6px; text-decoration: none;
  color: var(--text); transition: border-color 0.15s;
}
.update-file-attach:hover { border-color: var(--accent); }

.update-reactions {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px;
  align-items: center;
}
.reaction-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: 20px;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: 12px; cursor: pointer; transition: all 0.15s;
}
.reaction-btn:hover, .reaction-btn.reacted {
  border-color: var(--accent);
  background: rgba(37,99,235,0.08);
}
.add-reaction-btn {
  background: none; border: 1px dashed var(--border);
  border-radius: 20px; padding: 3px 8px;
  font-size: 13px; cursor: pointer; color: var(--muted);
  transition: all 0.15s;
}
.add-reaction-btn:hover { border-color: var(--accent); color: var(--accent); }

.update-footer {
  display: flex; align-items: center; gap: 12px;
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.reply-toggle-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--muted); font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  transition: color 0.15s;
}
.reply-toggle-btn:hover { color: var(--accent); }

.replies-section {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.reply-card {
  display: flex; gap: 8px; align-items: flex-start;
}
.reply-compose {
  display: flex; gap: 8px; align-items: flex-start; margin-top: 8px;
}
.reply-input {
  flex: 1; padding: 7px 12px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface2);
  font-size: 12px; color: var(--text); font-family: 'Montserrat',sans-serif;
  outline: none; transition: border-color 0.15s;
}
.reply-input:focus { border-color: var(--accent); }

/* Mention dropdown */
.mention-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  transition: background 0.1s;
}
.mention-item:hover, .mention-item.selected { background: var(--surface2); }

/* Emoji picker inline */
.emoji-picker-inline {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 6px;
}
.emoji-opt {
  font-size: 18px; cursor: pointer; padding: 4px;
  border-radius: 6px; transition: background 0.1s;
}
.emoji-opt:hover { background: var(--surface2); }

/* Attachment preview in compose */
.compose-attachment {
  position: relative; display: inline-block;
}
.compose-attachment img {
  width: 60px; height: 60px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
}
.compose-attachment-remove {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--red); color: #fff; border: none;
  font-size: 10px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}

/* Image lightbox */
.img-lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.img-lightbox img {
  max-width: 90vw; max-height: 90vh;
  border-radius: 8px; object-fit: contain;
}

/* ── TEAM SWITCHER ── */
.team-badge { transition: background 0.15s; }
.team-badge:hover { background: var(--surface2) !important; }
#team-switcher-dropdown > div:hover { background: var(--surface2) !important; }

/* ── CALENDAR MORE BUTTON ── */
.cal-more-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(37,99,235,0.07);
  border: none;
  border-radius: 4px;
  padding: 1px 5px;
  margin-top: 2px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'Montserrat', sans-serif;
}
.cal-more-btn:hover { background: rgba(37,99,235,0.15); }

/* ── FORMULA CELL ── */
.formula-cell {
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(37,99,235,0.04);
  border-left: 2px solid var(--accent);
}

/* ── FORMULA AUTOCOMPLETE ── */
.formula-ac-item:hover { background: var(--surface2) !important; }

/* ── WIKI ─────────────────────────────────────────── */
.wiki-tb-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s, border-color 0.1s;
  font-family: 'Montserrat', sans-serif;
  min-width: 26px;
  height: 26px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
}
.wiki-tb-btn:hover { background: var(--surface2); border-color: var(--border); }
.wiki-tb-btn.active { background: rgba(37,99,235,0.12); border-color: var(--accent); color: var(--accent); }
.wiki-tb-sep { width:1px; height:20px; background:var(--border); margin:0 3px; flex-shrink:0; }
.wiki-tb-select {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  padding: 2px 4px;
  height: 26px;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
}
.wiki-tb-select:focus { outline: none; border-color: var(--accent); }

.wiki-tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
  user-select: none;
  position: relative;
}
.wiki-tree-item:hover { background: var(--surface2); }
.wiki-tree-item.active { background: rgba(37,99,235,0.1); color: var(--accent); font-weight: 600; }
.wiki-tree-item .wiki-tree-actions {
  display: none;
  margin-left: auto;
  gap: 2px;
}
.wiki-tree-item:hover .wiki-tree-actions { display: flex; }
.wiki-tree-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
}
.wiki-tree-action-btn:hover { background: var(--border); color: var(--text); }

#wiki-editor { position: relative; }
#wiki-editor .tiptap { caret-color: var(--accent); font-size: 14px; outline: none; min-height: 200px; }
#wiki-editor .tiptap p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
  float: left;
  height: 0;
}
#wiki-editor .tiptap h1 { font-size: 36px; font-weight: 700; margin: 20px 0 8px; font-family: 'Montserrat', sans-serif; }
#wiki-editor .tiptap h2 { font-size: 24px; font-weight: 700; margin: 16px 0 6px; font-family: 'Montserrat', sans-serif; }
#wiki-editor .tiptap h3 { font-size: 18px; font-weight: 700; margin: 12px 0 4px; }
#wiki-editor .tiptap h4 { font-size: 14px; font-weight: 700; margin: 8px 0 4px; }
#wiki-editor .tiptap blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 4px 12px; color: var(--muted); font-style: italic; }
#wiki-editor .tiptap code { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-family: monospace; font-size: 12px; }
#wiki-editor .tiptap pre { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; overflow-x: auto; margin: 8px 0; }
#wiki-editor .tiptap pre code { background: none; border: none; padding: 0; }
#wiki-editor .tiptap ul, #wiki-editor .tiptap ol { padding-left: 20px; margin: 6px 0; }
#wiki-editor .tiptap li { margin: 2px 0; }
#wiki-editor .tiptap li p { margin: 0; }
#wiki-editor .tiptap hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
#wiki-editor .tiptap a { color: var(--accent); text-decoration: underline; }
#wiki-editor .tiptap table { border-collapse: collapse; width: 100%; margin: 12px 0; }
#wiki-editor .tiptap th, #wiki-editor .tiptap td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; font-size: 13px; }
#wiki-editor .tiptap th { background: var(--surface); font-weight: 700; }
#wiki-editor .tiptap .tableWrapper { overflow-x: auto; margin: 12px 0; }
#wiki-editor .tiptap .selectedCell { background: rgba(37,99,235,0.08); }

/* Slash command menu */
#wiki-slash-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: 500;
  overflow: hidden;
  min-width: 220px;
}
.wiki-slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}
.wiki-slash-item:hover, .wiki-slash-item.selected { background: var(--surface2); }
.wiki-slash-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }

@media (max-width: 768px) {
  #wiki-sidebar { width: 200px; min-width: 200px; }
  #wiki-editor .tiptap { padding: 16px; }
  #wiki-toolbar { padding: 8px 12px; gap: 4px; }
  .wiki-tb-btn { padding: 2px 6px; font-size: 11px; }
}

/* ── WIKI TABLE CONTEXT MENU ── */
#wiki-table-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  z-index: 600;
  overflow: hidden;
  min-width: 200px;
}
#wiki-table-menu div { padding: 9px 16px; cursor: pointer; font-size: 13px; transition: background 0.1s; }
#wiki-table-menu div:hover { background: var(--surface2); }
#wiki-table-menu .menu-sep { height: 1px; background: var(--border); padding: 0; margin: 2px 0; }
#wiki-editor .tiptap table { table-layout: fixed; }
#wiki-editor .tiptap table th, #wiki-editor .tiptap table td { min-width: 40px; position: relative; }
#wiki-editor .tiptap table th { resize: horizontal; overflow: hidden; }
.wiki-col-resizer {
  position: absolute;
  top: 0; right: -3px;
  width: 6px; height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
}
.wiki-col-resizer:hover, .wiki-col-resizer.resizing { background: var(--accent); opacity: 0.4; }
.wiki-table-selected { outline: 2px solid var(--accent); }
#wiki-editor .tiptap img { max-width: 100%; border-radius: 8px; cursor: pointer; display: block; margin: 8px 0; }
#wiki-editor .tiptap img.ProseMirror-selectednode { outline: 2px solid var(--accent); }

/* ── WIKI IMAGE WRAPPER ── */
.wiki-img-wrapper {
  display: block;
  position: relative;
  margin: 12px 0;
  line-height: 0;
  user-select: none;
}
.wiki-img-wrapper img { display: block; border-radius: 6px; cursor: default; max-width: 100%; }
.wiki-img-selected img { outline: 2px solid #1971c2; outline-offset: 1px; }
/* Resize overlay — position:absolute inside #wiki-editor, scrolls with content */
#wiki-resize-overlay { user-select: none; }
.wiki-insert-marker { display: none; width: 0; height: 0; overflow: hidden; }
kbd { display:inline-block;background:var(--surface);border:1px solid var(--border);border-radius:4px;padding:1px 6px;font-size:11px;font-family:'Montserrat',sans-serif;color:var(--text);box-shadow:0 1px 0 var(--border); }
.wiki-mention { background:rgba(37,99,235,0.1);color:var(--accent);border-radius:4px;padding:0 4px;font-weight:600;cursor:pointer; }
.wiki-mention-item.selected { background:var(--surface2); }
.wiki-callout-content > * { margin:0; }
mark.wiki-inline-comment { background:#fef08a;cursor:pointer;border-radius:2px; }
mark.wiki-inline-comment[data-resolved="true"] { opacity:0.4; }
.wiki-callout-content p:first-child { margin-top:0; }
#wiki-editor .tiptap [data-columns] { display:flex;gap:16px;margin:12px 0; }
#wiki-editor .tiptap [data-column] { flex:1;min-width:0;padding:0 8px;border-left:2px solid var(--border); }
#wiki-editor .tiptap [data-column]:first-child { border-left:none; }
#wiki-img-ctx { font-family: 'Montserrat', sans-serif; }

/* ── BLOG PUBLISH PANEL (Phase 12) ─────────────────────── */
.wiki-blog-field-label { display:flex;flex-direction:column;gap:3px;font-size:11px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.5px; }
.wiki-blog-input { background:var(--surface2);border:1px solid var(--border);border-radius:6px;padding:6px 8px;font-size:12px;color:var(--text);font-family:'Montserrat',sans-serif;width:100%;box-sizing:border-box; }
.wiki-blog-input:focus { outline:none;border-color:var(--accent); }
.wiki-blog-cat-item { display:flex;align-items:center;gap:6px;font-size:12px;color:var(--text);cursor:pointer;padding:2px 0; }
.wiki-blog-cat-item input[type=checkbox] { accent-color:var(--accent); }
.wiki-blog-status-badge { display:inline-block;font-size:11px;padding:3px 8px;border-radius:20px;background:var(--surface2);color:var(--muted); }
.wiki-blog-status-badge.published { background:rgba(34,197,94,.15);color:#16a34a; }
.wiki-blog-btn { border:none;border-radius:6px;padding:7px 10px;font-size:12px;font-weight:600;cursor:pointer;font-family:'Montserrat',sans-serif;transition:opacity .15s; }
.wiki-blog-btn:hover { opacity:.85; }
.wiki-blog-btn.primary { background:var(--accent);color:#fff; }
.wiki-blog-btn.secondary { background:var(--surface2);color:var(--text);border:1px solid var(--border); }
.wiki-blog-btn.danger { background:#dc2626;color:#fff; }
.wiki-blog-btn-sm { background:var(--surface2);border:1px solid var(--border);border-radius:5px;padding:4px 8px;font-size:12px;cursor:pointer;color:var(--muted); }

/* ═══════════════════════════════════════════════════════════
   SOCIAL CALENDAR (PostFlow style) + METRICS
   ═══════════════════════════════════════════════════════════ */

/* MONTH GRID */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.cal-day-header {
  background: var(--surface2);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-cell {
  background: var(--surface);
  min-height: 180px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: default;
  transition: background 0.15s;
}
.cal-cell:hover { background: var(--surface2); }
.cal-cell.empty {
  background: var(--surface2);
  opacity: 0.35;
}
.cal-cell.today {
  background: linear-gradient(180deg, rgba(91,141,238,0.10), transparent);
}
.cal-cell.today .cal-day-num {
  background: var(--accent);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cal-day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.cal-posts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow: hidden;
}

/* WEEK GRID — 7 cols, taller */
.cal-grid-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.cal-week-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  cursor: default;
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
}
.cal-week-col:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.cal-week-col.today {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(91,141,238,0.06), transparent);
}
.cal-week-header {
  padding: 12px 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.cal-week-dayname {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 700;
}
.cal-week-daynum {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.cal-week-daynum.today {
  background: var(--accent);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.cal-week-posts {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cal-week-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--border);
  font-weight: 300;
  cursor: pointer;
  border: 2px dashed transparent;
  border-radius: 8px;
  transition: all 0.15s;
}
.cal-week-col:hover .cal-week-empty {
  border-color: var(--border);
  color: var(--muted);
}

/* POSTFLOW-STYLE POST CARD */
.cal-post-pf {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  display: flex;
  flex-direction: column;
}
.cal-post-pf:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.10);
  border-color: var(--accent);
}

.cal-post-thumbwrap {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-post-thumbwrap.empty {
  background: linear-gradient(135deg, var(--surface2) 0%, rgba(91,141,238,0.08) 100%);
}
.cal-post-bigthumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cal-post-emptyicon {
  font-size: 32px;
  opacity: 0.5;
}

.cal-post-typebadge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  backdrop-filter: blur(4px);
}
.cal-post-carousel {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 10px;
  backdrop-filter: blur(4px);
}
.cal-post-statusbar {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.cal-post-info {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-post-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.cal-post-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}
.cal-post-nets {
  display: flex;
  gap: 3px;
}
.cal-post-netbadge {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
}
.cal-post-netbadge.fb { background: #1877f2; font-family: serif; }
.cal-post-netbadge.ig { background: linear-gradient(135deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888); font-size: 8px; }

.cal-post-caption {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cal-more {
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  padding: 4px 6px;
  text-align: center;
  border-radius: 6px;
  background: var(--surface2);
  margin-top: 2px;
}
.cal-more:hover { background: rgba(91,141,238,0.1); }

/* Mobile / tight grid: simplify cards */
@media (max-width: 900px) {
  .cal-cell { min-height: 130px; padding: 4px; gap: 4px; }
  .cal-post-thumbwrap { aspect-ratio: 16 / 9; }
  .cal-post-info { padding: 4px 6px; }
  .cal-post-time { font-size: 10px; }
  .cal-post-caption { display: none; }
  .cal-grid-week { grid-template-columns: 1fr; }
  .cal-week-col { min-height: auto; }
}

/* METRICS TABLE */
.metrics-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}
.metrics-table thead th {
  background: var(--surface2);
  padding: 10px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.metrics-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.metrics-table tbody tr:hover {
  background: var(--surface2);
}
.metrics-table tbody tr:last-child td {
  border-bottom: none;
}

/* ── MOBILE RESPONSIVE OVERRIDES ── */
@media (max-width: 768px) {
  /* Dashboard: charts row (2-col inline grid) */
  #view-dashboard > div[style*="grid-template-columns:1fr 1fr"],
  #view-dashboard > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Dashboard: weekly progress row (1fr auto -> stack) */
  #view-dashboard > div[style*="grid-template-columns:1fr auto"],
  #view-dashboard > div[style*="grid-template-columns: 1fr auto"] {
    grid-template-columns: 1fr !important;
  }

  /* Reports: stats row (4-col) and charts row (2-col) */
  #view-reports > div[style*="grid-template-columns:repeat(4"],
  #view-reports > div[style*="grid-template-columns: repeat(4"] {
    grid-template-columns: 1fr 1fr !important;
  }
  #view-reports > div[style*="grid-template-columns:1fr 1fr"],
  #view-reports > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* OKRs: stats row (4-col) */
  #okr-stats {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Notification panel: prevent overflow on narrow screens */
  #notif-panel {
    width: calc(100vw - 32px) !important;
    right: 16px !important;
    left: 16px !important;
    max-height: 70vh !important;
  }

  /* Wiki: stack sidebar + editor vertically */
  #wiki-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    max-height: 200px;
    overflow-y: auto;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
  }
  #view-wiki > div {
    flex-direction: column !important;
  }
  #wiki-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap !important;
  }
}

/* ============================================================
   SOCIAL PLANNER — Design System v4 (Meta Business Suite inspired)
   All classes prefixed .sp-* to avoid collision with existing styles.
   Dark mode: body.dark variable overrides handled at bottom.
   ============================================================ */

/* ── Design tokens ──────────────────────────────────────── */
:root {
  --sp-fb:           #1877F2;
  --sp-ig:           #E4405F;
  --sp-ig-grad:      linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  --sp-radius-card:  12px;
  --sp-shadow-card:  0 1px 4px rgba(0,0,0,.08);
  --sp-shadow-panel: 0 8px 32px rgba(0,0,0,.16);
  --sp-header-h:     60px;
  --sp-tab-h:        44px;
  --sp-panel-w:      400px;
  --sp-anim:         220ms ease;
}

/* ── View shell ─────────────────────────────────────────── */
#view-social {
  /* display is controlled by .view / .view.active — do NOT set display here */
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  padding: 0;
  background: var(--bg);
}

/* ── Header ─────────────────────────────────────────────── */
.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--sp-header-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 12px;
}
.sp-header-left  { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sp-header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.sp-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
}

.sp-account-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.sp-account-badge img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.sp-gear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--sp-anim), color var(--sp-anim);
}
.sp-gear-btn:hover { background: var(--surface2); color: var(--text); }

.sp-new-post-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}
.sp-new-post-btn:hover { opacity: .88; }

/* ── Tab navigation ─────────────────────────────────────── */
.sp-tabs {
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 0;
}
.sp-tabs::-webkit-scrollbar { display: none; }

.sp-tab {
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  height: var(--sp-tab-h);
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--sp-anim), border-color var(--sp-anim);
  margin-bottom: -1px;
}
.sp-tab:hover       { color: var(--text); }
.sp-tab.active      { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Reconnect banner ────────────────────────────────────── */
.sp-reconnect-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #fef9c3;
  color: #854d0e;
  font-size: 13px;
  border-bottom: 1px solid #fde68a;
  flex-shrink: 0;
}
body.dark .sp-reconnect-banner { background: #3b2c00; color: #fcd34d; border-color: #78350f; }
.sp-reconnect-banner button {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Tab panels ─────────────────────────────────────────── */
.sp-tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  min-height: 0;
}
.sp-hidden { display: none !important; }

/* ── Settings side panel ─────────────────────────────────── */
.sp-settings-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
  animation: spFadeIn var(--sp-anim) forwards;
}
.sp-settings-overlay.sp-hidden { display: none !important; }

@keyframes spFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes spSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.sp-settings-panel {
  width: var(--sp-panel-w);
  max-width: 100vw;
  background: var(--surface);
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sp-shadow-panel);
  animation: spSlideIn var(--sp-anim) forwards;
}
.sp-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sp-settings-header h2 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.sp-settings-close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background var(--sp-anim);
}
.sp-settings-close:hover { background: var(--surface2); color: var(--text); }
.sp-settings-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

/* ── Post modal ──────────────────────────────────────────── */
.sp-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.sp-modal-overlay.sp-hidden { display: none !important; }

.sp-post-modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sp-shadow-panel);
  display: flex;
  flex-direction: column;
}
.sp-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sp-modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.sp-modal-close {
  width: 32px; height: 32px; border-radius: 6px; border: none;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--sp-anim);
}
.sp-modal-close:hover { background: var(--surface2); color: var(--text); }
.sp-modal-body { padding: 20px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sp-modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ── Platform selectors (post modal) ────────────────────── */
.sp-platform-selector { display: flex; gap: 8px; flex-wrap: wrap; }
.sp-platform-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px; border: 2px solid var(--border);
  background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.sp-platform-btn.active-facebook  { border-color: var(--sp-fb); color: var(--sp-fb); background: rgba(24,119,242,.08); }
.sp-platform-btn.active-instagram { border-color: var(--sp-ig); color: var(--sp-ig); background: rgba(228,64,95,.08); }
.sp-platform-btn.active-both      { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb),.08); }
.sp-platform-btn.active-threads   { border-color: var(--text); color: var(--text); background: rgba(128,128,128,.1); }
.sp-platform-btn.active-all       { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb),.08); }

/* ── Post type tabs (modal) ─────────────────────────────── */
.sp-type-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.sp-type-tab {
  padding: 7px 14px; border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer;
  margin-bottom: -1px; transition: all .15s;
}
.sp-type-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Media upload zone ───────────────────────────────────── */
.sp-media-zone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 24px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
  background: var(--surface2); color: var(--muted); font-size: 13px;
}
.sp-media-zone:hover, .sp-media-zone.drag-over { border-color: var(--accent); background: rgba(var(--accent-rgb),.04); }
.sp-media-zone input[type="file"] { display: none; }

.sp-media-previews {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.sp-media-thumb {
  position: relative; width: 80px; height: 80px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
}
.sp-media-thumb img, .sp-media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.sp-media-thumb-remove {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.7); color: #fff; border: none; cursor: pointer; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Caption textarea ────────────────────────────────────── */
.sp-caption-area { position: relative; }
.sp-caption-area textarea {
  width: 100%; resize: vertical; min-height: 100px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 13px; font-family: inherit;
  line-height: 1.5; box-sizing: border-box; transition: border-color .15s;
}
.sp-caption-area textarea:focus { border-color: var(--accent); outline: none; }
.sp-char-counter {
  position: absolute; bottom: 8px; right: 10px; font-size: 11px;
  color: var(--muted); pointer-events: none;
}
.sp-char-counter.over { color: #dc2626; }

/* ── Schedule section ────────────────────────────────────── */
.sp-schedule-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sp-schedule-row label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.sp-schedule-row input[type="radio"] { accent-color: var(--accent); }
.sp-datetime-input {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 13px; font-family: inherit;
  transition: border-color .15s;
}
.sp-datetime-input:focus { border-color: var(--accent); outline: none; }

/* ── Filter bar ──────────────────────────────────────────── */
.sp-filter-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.sp-filter-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px;
  border-radius: 20px; border: 1px solid var(--border); background: var(--surface2);
  color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.sp-filter-chip:hover  { border-color: var(--accent); color: var(--text); }
.sp-filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ── Platform badge pills ────────────────────────────────── */
.sp-badge-fb, .sp-badge-ig, .sp-badge-both, .sp-badge-threads {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px;
  border-radius: 10px; font-size: 11px; font-weight: 600;
}
.sp-badge-fb      { background: rgba(24,119,242,.12); color: var(--sp-fb); }
.sp-badge-ig      { background: rgba(228,64,95,.12);  color: var(--sp-ig); }
.sp-badge-both    { background: rgba(120,120,120,.12); color: var(--muted); }
.sp-badge-threads { background: rgba(128,128,128,.1);  color: var(--text); }

/* ── Status chip ─────────────────────────────────────────── */
.sp-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.sp-chip-scheduled { background: #dbeafe; color: #1d4ed8; }
.sp-chip-published { background: #dcfce7; color: #166534; }
.sp-chip-partial   { background: #fef9c3; color: #854d0e; }
.sp-chip-failed    { background: #fee2e2; color: #991b1b; }
.sp-chip-draft     { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
body.dark .sp-chip-scheduled { background: #1e3a5f; color: #93c5fd; }
body.dark .sp-chip-published { background: #14532d; color: #86efac; }
body.dark .sp-chip-partial   { background: #3b2c00; color: #fcd34d; }
body.dark .sp-chip-failed    { background: #450a0a; color: #fca5a5; }

/* CRM */
.crm-shell { display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.crm-tabs {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
}
.crm-tabs::-webkit-scrollbar { display: none; }
.crm-tab {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 8px; padding: 12px 14px; font: inherit; cursor: pointer;
  transition: all .15s ease; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-width: 0; text-align: left;
}
.crm-tab:hover { color: var(--text); border-color: var(--accent); }
.crm-tab.active {
  background: rgba(var(--accent-rgb), .10); color: var(--accent); border-color: rgba(var(--accent-rgb), .28);
}
.crm-tab-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.crm-tab-title { color: var(--text); font-size: 13px; font-weight: 700; }
.crm-tab-sub { color: var(--muted); font-size: 11px; line-height: 1.35; white-space: normal; }
.crm-tab-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 54px;
  padding: 5px 8px; border-radius: 999px; background: var(--surface2); color: var(--text);
  font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.crm-tab.active .crm-tab-title,
.crm-tab.active .crm-tab-sub,
.crm-tab.active .crm-tab-count { color: var(--accent); }
.crm-tab.active .crm-tab-count { background: rgba(var(--accent-rgb), .14); }

.crm-pane { display: none; }
.crm-pane.active { display: block; }

.crm-overview {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
}
.crm-stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; min-width: 0;
}
.crm-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.crm-stat-value { font-size: 28px; line-height: 1.05; color: var(--text); font-weight: 800; margin-top: 8px; }
.crm-stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

.crm-grid {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .9fr); gap: 16px;
  align-items: start; margin-top: 16px;
}
.crm-main, .crm-side { min-width: 0; }
.crm-table-card, .crm-side-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.crm-table-card { overflow: hidden; min-height: 420px; }
.crm-side-card { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.crm-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.crm-stack { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.crm-banner { margin-top: 16px; }
.crm-toolbar-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.crm-toolbar-group-grow { flex: 1; min-width: 280px; }
.crm-search { min-width: 240px; flex: 1; }
.crm-filter { width: 190px; }

.crm-table-wrap { overflow: auto; }
.crm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.crm-table th {
  text-align: left; padding: 11px 14px; background: var(--surface2);
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.crm-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.crm-table tbody tr:hover td { background: var(--surface2); }
.crm-table tbody tr.active td { background: rgba(var(--accent-rgb), .08); }

.crm-contact-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.crm-contact-name { color: var(--text); font-weight: 700; }
.crm-contact-sub, .crm-cell-note { color: var(--muted); font-size: 12px; }
.crm-table-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.crm-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-tag, .crm-mini-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
  background: var(--surface2); color: var(--text); font-size: 11px; font-weight: 600;
}
.crm-mini-badge { margin-left: 6px; color: #8b5cf6; }
.crm-break-all { overflow-wrap: anywhere; }

.crm-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 104px;
  padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.crm-badge.synced { background: rgba(34,197,94,.12); color: #15803d; }
.crm-badge.pending { background: rgba(245,158,11,.14); color: #b45309; }
.crm-badge.error { background: rgba(239,68,68,.12); color: #b91c1c; }
.crm-badge.conflict { background: rgba(139,92,246,.12); color: #7c3aed; }
.crm-badge.draft { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.crm-badge.queued { background: rgba(245,158,11,.14); color: #b45309; }
.crm-badge.sent { background: rgba(59,130,246,.14); color: #1d4ed8; }
.crm-badge.delivered { background: rgba(34,197,94,.12); color: #15803d; }
.crm-badge.opened { background: rgba(6,182,212,.14); color: #0e7490; }
.crm-badge.clicked { background: rgba(14,165,233,.14); color: #0369a1; }
.crm-badge.bounced { background: rgba(249,115,22,.14); color: #c2410c; }
.crm-badge.spam { background: rgba(217,70,239,.14); color: #a21caf; }
.crm-badge.unsub { background: rgba(148,163,184,.18); color: #475569; }
.crm-badge.failed { background: rgba(239,68,68,.12); color: #b91c1c; }

.crm-history { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-history-item {
  display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px;
  background: var(--surface2); color: var(--text); font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.crm-history-item.queued { background: rgba(245,158,11,.14); color: #b45309; }
.crm-history-item.sent { background: rgba(59,130,246,.14); color: #1d4ed8; }
.crm-history-item.delivered { background: rgba(34,197,94,.12); color: #15803d; }
.crm-history-item.opened { background: rgba(6,182,212,.14); color: #0e7490; }
.crm-history-item.clicked { background: rgba(14,165,233,.14); color: #0369a1; }
.crm-history-item.bounced { background: rgba(249,115,22,.14); color: #c2410c; }
.crm-history-item.spam { background: rgba(217,70,239,.14); color: #a21caf; }
.crm-history-item.unsub { background: rgba(148,163,184,.18); color: #475569; }
.crm-history-item.failed { background: rgba(239,68,68,.12); color: #b91c1c; }

.crm-actions-cell { width: 1%; white-space: nowrap; text-align: right; }
.crm-row-btn, .crm-link-btn {
  border: none; background: transparent; color: var(--accent); font: inherit; font-size: 12px;
  font-weight: 700; cursor: pointer; padding: 0;
}
.crm-row-btn:hover, .crm-link-btn:hover { opacity: .78; }

.crm-side-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.crm-side-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.crm-side-title { color: var(--text); font-size: 20px; font-weight: 800; margin-top: 4px; }
.crm-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.crm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.crm-field span { font-size: 12px; color: var(--muted); font-weight: 600; }
.crm-field-full { grid-column: 1 / -1; }
.crm-textarea {
  min-height: 110px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.crm-textarea-lg { min-height: 220px; }
.crm-divider { height: 1px; background: var(--border); margin: 2px 0; }
.crm-link-stack { display: flex; flex-direction: column; gap: 10px; }
.crm-member-list {
  display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto;
  padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2);
}
.crm-member-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px; border-radius: 8px;
  background: var(--surface); border: 1px solid transparent;
}
.crm-member-item:hover { border-color: rgba(var(--accent-rgb), .22); }
.crm-member-item input { margin-top: 2px; accent-color: var(--accent); }
.crm-member-item span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.crm-member-item strong { color: var(--text); font-size: 13px; font-weight: 700; }
.crm-member-item small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.crm-checkbox { display: inline-flex; gap: 10px; align-items: center; color: var(--text); font-size: 13px; font-weight: 500; }
.crm-checkbox input { accent-color: var(--accent); }
.crm-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.crm-form-actions-end { justify-content: flex-end; }
.crm-form-actions-wrap { flex-wrap: wrap; }
.crm-toolbar-group-end { margin-left: auto; justify-content: flex-end; }
.crm-preset-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
.crm-preset-btn {
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
  text-align: left; cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.crm-preset-btn:hover { border-color: rgba(var(--accent-rgb), .32); background: rgba(var(--accent-rgb), .06); }
.crm-preset-title { font-size: 12px; font-weight: 700; color: var(--text); }
.crm-preset-sub { font-size: 11px; color: var(--muted); line-height: 1.35; }

.crm-inline-note {
  border-radius: 8px; padding: 10px 12px; background: rgba(var(--accent-rgb), .08);
  color: var(--accent); font-size: 12px; line-height: 1.45;
}
.crm-inline-note.error { background: rgba(239,68,68,.10); color: #b91c1c; }
.crm-inline-note-muted {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.crm-inline-note-grid { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.crm-inline-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px;
  background: var(--surface2); color: var(--text); font-size: 12px; font-weight: 600;
}
.crm-inline-chip strong { font-weight: 800; }
.crm-settings-stack { display: flex; flex-direction: column; gap: 16px; }
.crm-settings-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.crm-settings-section-title {
  color: var(--text); font-size: 14px; font-weight: 800;
}
.crm-settings-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.crm-settings-item {
  min-width: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2);
}
.crm-settings-item-wide { grid-column: 1 / -1; }
.crm-settings-item-label {
  color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.crm-settings-item-value {
  min-width: 0; color: var(--text); font-size: 14px; font-weight: 700;
}
.crm-settings-item-text {
  color: var(--text); font-size: 14px; font-weight: 700; overflow-wrap: anywhere;
}
.crm-settings-probe-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px;
}
.crm-muted { color: var(--muted); font-size: 12px; }

.crm-loading, .crm-empty, .crm-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 240px; text-align: center; padding: 28px;
}
.crm-empty-title { color: var(--text); font-size: 15px; font-weight: 700; }
.crm-empty-copy { color: var(--muted); font-size: 13px; max-width: 320px; line-height: 1.45; }
.crm-empty-icon { color: var(--muted); font-size: 28px; opacity: .65; }

.crm-spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border);
  border-top-color: var(--accent); animation: crm-spin .7s linear infinite;
}
@keyframes crm-spin { to { transform: rotate(360deg); } }

@media (max-width: 1080px) {
  .crm-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-grid { grid-template-columns: 1fr; }
  .crm-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .crm-tabs { grid-template-columns: 1fr; }
  .crm-overview { grid-template-columns: 1fr 1fr; gap: 10px; }
  .crm-toolbar-group-grow { min-width: 0; width: 100%; }
  .crm-search, .crm-filter { width: 100%; min-width: 0; }
  .crm-form-grid { grid-template-columns: 1fr; }
  .crm-form-actions { flex-direction: column-reverse; align-items: stretch; }
  .crm-badge { min-width: 0; }
  .crm-settings-grid { grid-template-columns: 1fr; }
  .crm-preset-grid { grid-template-columns: 1fr; }
  #crm-contacts-table-wrap .crm-table th:nth-child(3), #crm-contacts-table-wrap .crm-table td:nth-child(3),
  #crm-contacts-table-wrap .crm-table th:nth-child(5), #crm-contacts-table-wrap .crm-table td:nth-child(5) { display: none; }
  #crm-lists-table-wrap .crm-table th:nth-child(4), #crm-lists-table-wrap .crm-table td:nth-child(4),
  #crm-lists-table-wrap .crm-table th:nth-child(5), #crm-lists-table-wrap .crm-table td:nth-child(5),
  #crm-lists-table-wrap .crm-table th:nth-child(6), #crm-lists-table-wrap .crm-table td:nth-child(6) { display: none; }
  #crm-marketing-table-wrap .crm-table th:nth-child(4), #crm-marketing-table-wrap .crm-table td:nth-child(4),
  #crm-marketing-table-wrap .crm-table th:nth-child(5), #crm-marketing-table-wrap .crm-table td:nth-child(5),
  #crm-marketing-table-wrap .crm-table th:nth-child(6), #crm-marketing-table-wrap .crm-table td:nth-child(6) { display: none; }
  #crm-events-table-wrap .crm-table th:nth-child(4), #crm-events-table-wrap .crm-table td:nth-child(4),
  #crm-events-table-wrap .crm-table th:nth-child(5), #crm-events-table-wrap .crm-table td:nth-child(5) { display: none; }
  #crm-tx-table-wrap .crm-table th:nth-child(4), #crm-tx-table-wrap .crm-table td:nth-child(4),
  #crm-tx-table-wrap .crm-table th:nth-child(5), #crm-tx-table-wrap .crm-table td:nth-child(5) { display: none; }
}

/* ── Post card grid ──────────────────────────────────────── */
.sp-post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.sp-post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--sp-radius-card);
  box-shadow: var(--sp-shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--sp-anim), transform var(--sp-anim);
  cursor: pointer;
}
.sp-post-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: translateY(-1px); }

.sp-post-thumb {
  width: 100%; aspect-ratio: 16/9; background: var(--surface2);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  position: relative; flex-shrink: 0;
}
.sp-post-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sp-post-thumb-placeholder {
  font-size: 32px; opacity: .35; user-select: none;
}
.sp-post-thumb-video-badge {
  position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.6);
  color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
}

.sp-post-info { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sp-post-caption {
  font-size: 13px; color: var(--text); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sp-post-meta  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-post-date  { font-size: 11px; color: var(--muted); }
.sp-post-actions {
  display: flex; gap: 4px; padding-top: 6px; border-top: 1px solid var(--border);
  margin-top: auto;
}
.sp-post-action-btn {
  flex: 1; padding: 5px; border-radius: 6px; border: none; background: transparent;
  color: var(--muted); font-size: 11px; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.sp-post-action-btn:hover { background: var(--surface2); color: var(--text); }
.sp-post-action-btn.danger:hover { background: #fee2e2; color: #dc2626; }

/* ── Calendar ────────────────────────────────────────────── */
.sp-cal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}
.sp-cal-nav { display: flex; align-items: center; gap: 6px; }
.sp-cal-title { font-size: 16px; font-weight: 700; color: var(--text); min-width: 160px; }
.sp-cal-view-btns { display: flex; gap: 4px; }
.sp-cal-view-btn {
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.sp-cal-view-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

.sp-cal-btn {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.sp-cal-btn:hover { background: var(--surface); }

.sp-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--border); border-radius: 8px; overflow: hidden;
}
.sp-cal-day-name {
  background: var(--surface2); padding: 6px; text-align: center;
  font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase;
}
.sp-cal-cell {
  background: var(--surface); min-height: 90px; padding: 6px;
  display: flex; flex-direction: column; gap: 3px;
  cursor: pointer; transition: background .12s;
}
.sp-cal-cell:hover { background: var(--surface2); }
.sp-cal-cell.other-month .sp-cal-cell-num { opacity: .35; }
.sp-cal-cell.today .sp-cal-cell-num {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
}
.sp-cal-cell-num { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.sp-cal-event-dot {
  font-size: 10px; padding: 1px 5px; border-radius: 3px; color: #fff; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.sp-cal-event-dot.fb  { background: var(--sp-fb); }
.sp-cal-event-dot.ig  { background: var(--sp-ig); }
.sp-cal-event-dot.both { background: var(--accent); }

/* Calendar week view */
.sp-cal-week { display: grid; grid-template-columns: 50px repeat(7, 1fr); gap: 1px; background: var(--border); border-radius: 8px; overflow: hidden; }
.sp-cal-week-header { background: var(--surface2); padding: 6px 4px; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.sp-cal-week-slot { background: var(--surface); min-height: 48px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; padding: 2px 4px; }
.sp-cal-week-time { background: var(--surface2); display: flex; align-items: flex-start; justify-content: flex-end; padding: 4px 6px 0; font-size: 10px; color: var(--muted); }

/* Calendar list view */
.sp-cal-list-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.sp-cal-list-date { min-width: 60px; text-align: right; font-size: 12px; color: var(--muted); padding-top: 2px; }

/* ── Comments ────────────────────────────────────────────── */
.sp-comment-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; display: flex; gap: 12px; margin-bottom: 8px;
  transition: border-color .15s;
}
.sp-comment-card:hover { border-color: var(--accent); }
.sp-comment-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: var(--surface2); display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--muted);
}
.sp-comment-body { flex: 1; min-width: 0; }
.sp-comment-author { font-size: 13px; font-weight: 600; color: var(--text); }
.sp-comment-text   { font-size: 13px; color: var(--text); margin: 4px 0; line-height: 1.4; }
.sp-comment-meta   { font-size: 11px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.sp-comment-reply-form { margin-top: 8px; display: flex; gap: 6px; }
.sp-comment-reply-form textarea {
  flex: 1; resize: none; padding: 6px 10px; border-radius: 8px; height: 36px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  font-size: 12px; font-family: inherit; transition: border-color .15s;
}
.sp-comment-reply-form textarea:focus { border-color: var(--accent); outline: none; height: 64px; }

/* ── Messages ────────────────────────────────────────────── */
.sp-messages-pane {
  display: flex; gap: 0; height: calc(100vh - var(--sp-header-h) - var(--sp-tab-h) - 40px);
  min-height: 400px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--surface);
}
.sp-conv-list {
  width: 280px; min-width: 280px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sp-conv-list-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.sp-conv-scroll { flex: 1; overflow-y: auto; }
.sp-conv-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  cursor: pointer; border-bottom: 1px solid var(--border); transition: background .12s;
}
.sp-conv-item:hover { background: var(--surface2); }
.sp-conv-item.active { background: rgba(var(--accent-rgb),.08); }
.sp-conv-avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: var(--surface2); display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.sp-conv-info { flex: 1; min-width: 0; }
.sp-conv-name    { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-conv-snippet { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.sp-conv-time    { font-size: 10px; color: var(--muted); flex-shrink: 0; }

.sp-thread-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sp-thread-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text); flex-shrink: 0; }
.sp-thread-scroll { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.sp-msg-bubble {
  max-width: 70%; padding: 8px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.4; word-break: break-word;
}
.sp-msg-sent { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.sp-msg-recv { align-self: flex-start; background: var(--surface2); color: var(--text); border-bottom-left-radius: 4px; }
.sp-msg-time { font-size: 10px; opacity: .65; display: block; margin-top: 3px; }
.sp-reply-bar {
  display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.sp-reply-bar input {
  flex: 1; padding: 8px 12px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 13px; font-family: inherit;
  transition: border-color .15s;
}
.sp-reply-bar input:focus { border-color: var(--accent); outline: none; }
.sp-reply-send {
  padding: 8px 14px; border-radius: 20px; border: none; background: var(--accent);
  color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: opacity .15s;
}
.sp-reply-send:hover { opacity: .85; }

/* ── Metrics dashboard ───────────────────────────────────── */
.sp-metrics-range-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.sp-range-quick-btn {
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.sp-range-quick-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.sp-range-sep { color: var(--muted); font-size: 12px; }
.sp-range-input {
  padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 12px; font-family: inherit;
}

.sp-kpi-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px;
}
.sp-kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--sp-radius-card);
  padding: 16px; box-shadow: var(--sp-shadow-card);
}
.sp-kpi-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.sp-kpi-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.sp-kpi-trend { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; margin-top: 6px; }
.sp-trend-up   { color: #16a34a; }
.sp-trend-down { color: #dc2626; }
.sp-trend-flat { color: var(--muted); }

.sp-chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--sp-radius-card);
  padding: 20px; box-shadow: var(--sp-shadow-card); margin-bottom: 16px;
}
.sp-chart-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sp-chart-title { font-size: 14px; font-weight: 700; color: var(--text); }
.sp-chart-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sp-chart-container { position: relative; }
.sp-chart-container canvas { display: block; }

.sp-metrics-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.sp-metrics-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }

.sp-gauge-wrap { display: flex; gap: 20px; align-items: flex-start; }
.sp-gauge-canvas-wrap { flex-shrink: 0; }
.sp-gauge-table { flex: 1; min-width: 0; }
.sp-gauge-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.sp-gauge-row:last-child { border-bottom: none; }
.sp-gauge-row-label { color: var(--muted); }
.sp-gauge-row-val   { font-weight: 600; color: var(--text); }

.sp-engagement-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sp-engagement-table th { text-align: left; padding: 6px 10px; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--border); white-space: nowrap; }
.sp-engagement-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.sp-engagement-table tr:last-child td { border-bottom: none; }

.sp-top-posts-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sp-top-posts-table th { text-align: left; padding: 6px 10px; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--border); cursor: pointer; white-space: nowrap; }
.sp-top-posts-table th:hover { color: var(--text); }
.sp-top-posts-table th.sorted { color: var(--accent); }
.sp-top-posts-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.sp-top-posts-table tr:last-child td { border-bottom: none; }
.sp-top-posts-table tr:hover td { background: var(--surface2); }
.sp-top-post-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--surface2); }
.sp-top-post-caption { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Resumen General ─────────────────────────────────────── */
.sp-resumen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }

.sp-account-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--sp-radius-card);
  padding: 20px; box-shadow: var(--sp-shadow-card); display: flex; flex-direction: column; gap: 12px;
}
.sp-account-card-header { display: flex; align-items: center; gap: 12px; }
.sp-account-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--surface2); flex-shrink: 0; }
.sp-account-name   { font-size: 15px; font-weight: 700; color: var(--text); }
.sp-account-handle { font-size: 12px; color: var(--muted); }
.sp-account-status { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.sp-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sp-status-dot.connected    { background: #16a34a; }
.sp-status-dot.disconnected { background: #dc2626; }
.sp-status-dot.expiring     { background: #d97706; }
.sp-account-stat { font-size: 13px; color: var(--muted); }
.sp-account-stat strong { color: var(--text); font-weight: 700; }

.sp-quick-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.sp-quick-stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--sp-radius-card);
  padding: 16px; text-align: center; box-shadow: var(--sp-shadow-card);
}
.sp-quick-stat-num   { font-size: 28px; font-weight: 700; color: var(--text); }
.sp-quick-stat-label { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }

.sp-resumen-section { margin-bottom: 24px; }
.sp-resumen-section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }

.sp-mini-post-list { display: flex; flex-direction: column; gap: 8px; }
.sp-mini-post-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  transition: border-color .15s;
}
.sp-mini-post-item:hover { border-color: var(--accent); }
.sp-mini-thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--surface2); flex-shrink: 0; }
.sp-mini-post-info { flex: 1; min-width: 0; }
.sp-mini-post-caption { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-mini-post-meta    { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sp-quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sp-quick-action-btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.sp-quick-action-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb),.06); }
.sp-quick-action-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.sp-quick-action-btn.primary:hover { opacity: .88; }

/* ── Settings panel components ───────────────────────────── */
.sp-settings-section { display: flex; flex-direction: column; gap: 10px; }
.sp-settings-section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.sp-conn-card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.sp-conn-card-header { display: flex; align-items: center; gap: 10px; }
.sp-conn-platform-icon {
  width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.sp-conn-platform-icon.fb { background: var(--sp-fb); }
.sp-conn-platform-icon.ig { background: var(--sp-ig-grad); }
.sp-conn-details { flex: 1; min-width: 0; }
.sp-conn-name   { font-size: 14px; font-weight: 600; color: var(--text); }
.sp-conn-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.sp-conn-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.sp-settings-input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
  box-sizing: border-box; transition: border-color .15s;
}
.sp-settings-input:focus { border-color: var(--accent); outline: none; }

.sp-btn-primary, .sp-btn-ghost, .sp-btn-danger {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 7px;
  border: none; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.sp-btn-primary { background: var(--accent); color: #fff; }
.sp-btn-primary:hover { opacity: .88; }
.sp-btn-ghost   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.sp-btn-ghost:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.sp-btn-danger  { background: transparent; color: #dc2626; border: 1px solid #dc2626; }
.sp-btn-danger:hover { background: #fee2e2; }

/* ── Empty state ─────────────────────────────────────────── */
.sp-empty {
  text-align: center; padding: 60px 24px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.sp-empty-icon  { font-size: 48px; opacity: .35; }
.sp-empty-title { font-size: 15px; font-weight: 600; color: var(--text); }
.sp-empty-desc  { font-size: 13px; color: var(--muted); max-width: 280px; line-height: 1.4; }

/* ── Loading spinner ─────────────────────────────────────── */
.sp-spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: sp-spin .7s linear infinite; flex-shrink: 0;
}
@keyframes sp-spin { to { transform: rotate(360deg); } }
.sp-loading { display: flex; align-items: center; justify-content: center; padding: 40px; }

/* ── Page-select dropdown (settings) ─────────────────────── */
.sp-page-select-list { display: flex; flex-direction: column; gap: 6px; }
.sp-page-option {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: all .15s;
}
.sp-page-option:hover  { border-color: var(--accent); background: rgba(var(--accent-rgb),.04); }
.sp-page-option.active { border-color: var(--accent); background: rgba(var(--accent-rgb),.08); }
.sp-page-option img    { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; }
.sp-page-option-name   { font-size: 13px; font-weight: 600; color: var(--text); }
.sp-page-option-id     { font-size: 11px; color: var(--muted); }

/* ── Mobile / Métricas scroll-snap (≤768px) ──────────────── */
@media (max-width: 768px) {
  .sp-kpi-grid    { grid-template-columns: repeat(2, 1fr); }
  .sp-metrics-2col, .sp-metrics-3col { grid-template-columns: 1fr; }
  .sp-resumen-grid    { grid-template-columns: 1fr; }
  .sp-quick-stats     { grid-template-columns: repeat(2, 1fr); }
  .sp-post-grid       { grid-template-columns: 1fr; }

  .sp-messages-pane   { flex-direction: column; height: auto; min-height: 0; }
  .sp-conv-list       { width: 100%; min-width: 0; max-height: 240px; border-right: none; border-bottom: 1px solid var(--border); }
  .sp-thread-pane     { min-height: 300px; }

  .sp-metrics-scroll-snap {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch; gap: 16px; padding-bottom: 12px;
    scrollbar-width: none;
  }
  .sp-metrics-scroll-snap::-webkit-scrollbar { display: none; }
  .sp-metrics-snap-page {
    flex: 0 0 calc(100vw - 40px); scroll-snap-align: start;
    min-width: 0; display: flex; flex-direction: column; gap: 16px;
  }
  .sp-chart-container canvas { min-height: 220px; }
  .sp-gauge-wrap { flex-direction: column; }
  .sp-gauge-canvas-wrap canvas { max-width: 100%; height: auto !important; }

  /* Dot pagination (rendered by JS) */
  .sp-snap-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
  .sp-snap-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); transition: background .2s; }
  .sp-snap-dot.active { background: var(--accent); }

  .sp-top-posts-table { font-size: 11px; }
  .sp-top-posts-table th, .sp-top-posts-table td { padding: 6px 6px; }
  .sp-top-post-caption { max-width: 100px; }
  .sp-top-post-thumb { width: 32px; height: 32px; }

  .sp-settings-panel { width: 100vw; }
}

@media (max-width: 480px) {
  .sp-header { padding: 0 12px; }
  .sp-tabs   { padding: 0 12px; }
  .sp-tab    { padding: 0 10px; font-size: 12px; }
  .sp-tab-panel { padding: 12px; }
  .sp-kpi-value { font-size: 20px; }
  .sp-title     { font-size: 16px; }
  .sp-new-post-btn { padding: 7px 10px; font-size: 12px; }
  .sp-post-grid { grid-template-columns: 1fr; }
}

/* ── Dark mode overrides ─────────────────────────────────── */
body.dark .sp-post-card,
body.dark .sp-chart-card,
body.dark .sp-kpi-card,
body.dark .sp-account-card,
body.dark .sp-quick-stat-card,
body.dark .sp-comment-card,
body.dark .sp-mini-post-item,
body.dark .sp-conn-card,
body.dark .sp-page-option {
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
body.dark .sp-post-modal {
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
body.dark .sp-badge-fb      { background: rgba(24,119,242,.2); }
body.dark .sp-badge-ig      { background: rgba(228,64,95,.2); }
body.dark .sp-badge-threads { background: rgba(255,255,255,.12); color: #fff; }
body.dark .sp-chip-scheduled { background: #1e3a5f; color: #93c5fd; }
body.dark .sp-chip-published { background: #14532d; color: #86efac; }
body.dark .sp-chip-partial   { background: #3b2c00; color: #fcd34d; }
body.dark .sp-chip-failed    { background: #450a0a; color: #fca5a5; }
