/* =============================================
   SCALE PILOT PORTAL — portal-style.css
   Dark Purple Theme — matches landing page
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Kill browser autofill white background on all inputs */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px #111111 inset !important;
  box-shadow: 0 0 0px 1000px #111111 inset !important;
  -webkit-text-fill-color: rgba(255,255,255,0.90) !important;
  caret-color: rgba(255,255,255,0.90) !important;
  transition: background-color 5000s ease-in-out 0s;
}

:root {
  --bg-primary:    #080808;
  --bg-secondary:  #111111;
  --bg-card:       rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --bg-input:      rgba(255,255,255,0.05);
  --accent:        #00c9a7;
  --accent-dark:   #009e87;
  --accent-dim:    rgba(0,201,167,0.12);
  --green:         #00c9a7;
  --yellow:        #eab308;
  --red:           #ef4444;
  --blue:          #3b82f6;
  --text-primary:  rgba(255,255,255,0.90);
  --text-secondary:rgba(255,255,255,0.50);
  --text-muted:    rgba(255,255,255,0.22);
  --border:        rgba(255,255,255,0.09);
  --border-hover:  rgba(0,201,167,0.45);
  --glow:          0 0 40px rgba(0,201,167,0.12);
  --radius:        12px;
  --radius-sm:     9px;
  --radius-xs:     6px;
  --sidebar-w:     250px;
  --transition:    0.25s cubic-bezier(0.4,0,0.2,1);
  --border-b:      rgba(255,255,255,0.09);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* LOADING SCREEN */
#loadingScreen {
  position: fixed; inset: 0; background: var(--bg-primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; gap: 16px;
}
.loading-logo {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.7;transform:scale(0.95)} }
#loadingScreen p { color: var(--text-muted); font-size: 0.85rem; }

/* LAYOUT */
#portalLayout { display: none; min-height: 100vh; }
.portal-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200; transition: transform var(--transition);
}
.sidebar-header {
  padding: 22px 20px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
  width: 38px; height: 38px; flex-shrink: 0;
  background: var(--accent);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.sidebar-brand { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.sidebar-brand span { display: block; font-size: 0.7rem; font-weight: 400; color: var(--text-muted); }

.sidebar-user {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #fff;
}
.user-info-side { overflow: hidden; }
.user-name-side { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-side { font-size: 0.7rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section-label {
  font-size: 0.65rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em; padding: 10px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: var(--transition); border: none;
  background: none; width: 100%; text-align: left; position: relative;
  font-family: inherit;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: rgba(0,201,167,0.12); color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--accent-dark));
}
.nav-icon { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--accent);
  color: #fff; font-size: 0.65rem; font-weight: 700;
  padding: 2px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border); }

/* MAIN CONTENT */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(8,8,8,0.92); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 60px;
  display: flex; align-items: center; gap: 16px;
}
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.hamburger-portal {
  display: none; background: none; border: none;
  color: var(--text-primary); font-size: 1.3rem; cursor: pointer; padding: 4px;
}
.page-content { padding: 28px; flex: 1; }

/* SECTIONS */
.portal-section { display: none; }
.portal-section.active { display: block; padding-top: 4px; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.stat-icon { font-size: 1.5rem; margin-bottom: 10px; }

/* PANEL */
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
.panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.panel-body { padding: 20px; }

/* TABS */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: var(--bg-card); border-radius: var(--radius-sm);
  padding: 4px; border: 1px solid var(--border);
}
.tab-btn {
  flex: 1; padding: 8px 12px; border-radius: 8px;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  border: none; background: none; color: var(--text-muted);
  transition: var(--transition); text-align: center; font-family: inherit;
}
.tab-btn.active { background: rgba(0,201,167,0.2); color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: sectionFadeIn 0.15s ease; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); white-space: nowrap; font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 16px rgba(0,201,167,0.3); }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-ghost { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary); }
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text-primary); }
.btn-danger { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #ef4444; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: #22c55e; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-xs { padding: 4px 8px; font-size: 0.72rem; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  color: var(--text-primary); font-size: 0.875rem; font-family: inherit;
  transition: var(--transition); outline: none;
}
.form-control:focus { border-color: var(--accent); background: rgba(0,201,167,0.08); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
option { background: #111111; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* Cost stepper */
.cost-stepper { display: flex; align-items: center; gap: 0; }
.cost-stepper .stepper-input { border-radius: 0; text-align: center; -moz-appearance: textfield; flex: 1; min-width: 0; }
.cost-stepper .stepper-input::-webkit-inner-spin-button,
.cost-stepper .stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-btn {
  width: 40px; height: 40px; flex-shrink: 0;
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--green); font-size: 1.3rem; font-weight: 700; line-height: 1;
  cursor: pointer; transition: all 0.18s; display: flex; align-items: center; justify-content: center;
}
.stepper-btn:first-child { border-radius: 8px 0 0 8px; border-right: none; }
.stepper-btn:last-child  { border-radius: 0 8px 8px 0; border-left: none; }
.stepper-btn:hover { background: var(--green); color: #000; }

/* TABLE */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid rgba(0,201,167,0.06); color: var(--text-secondary); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table td strong { color: var(--text-primary); }
.table-wrap { overflow-x: auto; }

/* BADGES */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-active   { background: rgba(34,197,94,0.15);  color: #22c55e; }
.badge-expiring { background: rgba(234,179,8,0.15);  color: #eab308; }
.badge-expired  { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-pending  { background: rgba(234,179,8,0.15);  color: #eab308; }
.badge-admin    { background: rgba(0,201,167,0.2);  color: var(--accent); }
.badge-team     { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-client   { background: rgba(34,197,94,0.12);  color: #4ade80; }
.badge-paid     { background: rgba(34,197,94,0.15);  color: #22c55e; }
.badge-unpaid   { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-disabled { background: rgba(100,100,100,0.2); color: #6b7280; }

/* ALERT */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 16px; border: 1px solid; }
.alert-warning { background: rgba(234,179,8,0.1); border-color: rgba(234,179,8,0.3); color: #eab308; }
.alert-danger  { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #ef4444; }
.alert-success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); color: #22c55e; }
.alert-info    { background: rgba(0,201,167,0.1); border-color: rgba(0,201,167,0.3); color: var(--accent); }

/* CHAT */
.chat-layout { display: flex; height: calc(100vh - 148px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.chat-sidebar-panel { width: 280px; background: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.chat-sidebar-head { padding: 16px; border-bottom: 1px solid var(--border); }
.chat-sidebar-head h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 10px; }
.chat-search { width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text-primary); font-size: 0.8rem; outline: none; font-family: inherit; }
.chat-search:focus { border-color: var(--accent); }
.chat-contacts-list { flex: 1; overflow-y: auto; }
.chat-contact-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; cursor: pointer; transition: var(--transition);
  border-bottom: 1px solid rgba(0,201,167,0.05);
}
.chat-contact-item:hover { background: var(--bg-card); }
.chat-contact-item.active { background: rgba(0,201,167,0.1); }
.cc-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #fff; position: relative;
}
.cc-online { position: absolute; bottom: 1px; right: 1px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg-secondary); display: none; }
.presence-dot { display: none; width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); border: 2px solid var(--bg-secondary); }
.presence-dot.online { display: block; background: var(--green); }
.cc-info { flex: 1; overflow: hidden; }
.cc-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-preview { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.cc-time { font-size: 0.68rem; color: var(--text-muted); }
.cc-unread { background: var(--accent); color: #fff; font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 10px; }

.chat-main-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-primary); min-width: 0; }
.chat-main-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-shrink: 0; background: var(--bg-secondary); }
.chat-main-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; color: #fff; }
.chat-main-name { font-size: 0.9rem; font-weight: 700; }
.chat-main-status { font-size: 0.72rem; color: var(--green); }
.chat-messages-area { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-no-select { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--text-muted); font-size: 0.875rem; }
.chat-no-select-icon { font-size: 3rem; }

.msg-row { display: flex; gap: 8px; align-items: flex-end; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-av { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; color: #fff; }
.msg-body { max-width: 65%; }
.msg-bubble { padding: 10px 14px; border-radius: 16px; font-size: 0.875rem; line-height: 1.5; word-break: break-word; }
.msg-row.mine .msg-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg-row:not(.mine) .msg-bubble { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-time { font-size: 0.65rem; color: var(--text-muted); margin-top: 3px; }
.msg-row.mine .msg-time { text-align: right; }

.chat-input-wrap { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-secondary); flex-shrink: 0; position: relative; }
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-textarea {
  flex: 1; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px;
  color: var(--text-primary); font-size: 0.875rem; font-family: inherit;
  resize: none; outline: none; max-height: 120px; min-height: 42px;
  transition: var(--transition); line-height: 1.5;
}
.chat-textarea:focus { border-color: var(--accent); }
.emoji-toggle { background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: 6px 8px; border-radius: 8px; transition: var(--transition); }
.emoji-toggle:hover { background: var(--bg-card); }
.chat-send-btn { width: 42px; height: 42px; border-radius: 10px; border: none; background: var(--accent); color: #fff; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: var(--transition); }
.chat-send-btn:hover { opacity: 0.88; transform: scale(1.05); }

.emoji-picker-popup {
  position: absolute; bottom: 70px; left: 16px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; display: none; z-index: 100;
  width: 280px; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.emoji-picker-popup.open { display: block; }
.emoji-cats { display: flex; gap: 4px; margin-bottom: 8px; overflow-x: auto; }
.emoji-cat-btn { background: none; border: none; font-size: 1rem; cursor: pointer; padding: 4px 6px; border-radius: 6px; opacity: 0.6; transition: var(--transition); }
.emoji-cat-btn.active, .emoji-cat-btn:hover { background: var(--bg-card); opacity: 1; }
.emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; max-height: 180px; overflow-y: auto; }
.emoji-cell { font-size: 1.3rem; cursor: pointer; padding: 5px; border-radius: 6px; text-align: center; line-height: 1; transition: background var(--transition); }
.emoji-cell:hover { background: var(--bg-card); }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 560px; animation: modalIn 0.2s ease; }
@keyframes modalIn { from{opacity:0;transform:scale(0.95)} to{opacity:1;transform:scale(1)} }
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* FINANCE */
.finance-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.fc { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.fc-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.fc-value { font-size: 1.5rem; font-weight: 700; }
.fc-value.green { color: var(--green); }
.fc-value.red { color: var(--red); }
.fc-value.yellow { color: var(--yellow); }
.fc-value.purple { color: var(--accent); }

/* USER CARDS */
.user-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); transition: var(--transition); }
.user-card:last-child { border-bottom: none; }
.user-card:hover { background: var(--bg-card-hover); }
.uc-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700; color: #fff; }
.uc-info { flex: 1; }
.uc-name { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.uc-email { font-size: 0.75rem; color: var(--text-muted); }
.uc-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.875rem; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,201,167,0.3); border-radius: 10px; }

/* SIDEBAR OVERLAY */
#sidebarOverlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 190; }

/* RESPONSIVE */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger-portal { display: flex !important; }
  .chat-layout {
    flex-direction: row;
    height: calc(100vh - 110px);
    position: relative;
    overflow: hidden;
  }
  /* Sidebar: full width, slides in/out */
  .chat-sidebar-panel {
    position: absolute; inset: 0; z-index: 2;
    width: 100%; height: 100%;
    transform: translateX(0);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  }
  /* When a chat is open, slide sidebar out to the left */
  .chat-layout.chat-open .chat-sidebar-panel {
    transform: translateX(-100%);
    pointer-events: none;
  }
  /* Main panel: full width, starts off-screen to the right */
  .chat-main-panel {
    position: absolute; inset: 0; z-index: 1;
    width: 100%; height: 100%;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  }
  .chat-layout.chat-open .chat-main-panel {
    transform: translateX(0);
  }
  /* Back button — only visible on mobile */
  .chat-back-btn {
    display: flex !important;
  }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .finance-summary { grid-template-columns: 1fr 1fr; }
  .tab-bar { flex-wrap: wrap; }
}

/* ── AUTH PAGES (login / register) ──────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary); padding: 24px 16px; position: relative;
}
.auth-page::before {
  content: ''; position: fixed; top: -200px; right: -200px;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,201,167,0.1) 0%, transparent 70%);
  pointer-events: none;
}
.back-btn {
  position: fixed; top: 20px; left: 20px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 8px 14px; border-radius: 8px;
  font-size: 0.82rem; cursor: pointer; font-family: inherit;
  transition: var(--transition); text-decoration: none;
}
.back-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }

.auth-box {
  width: 100%; max-width: 420px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 20px; padding: 36px 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4), var(--glow);
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; margin-bottom: 28px;
}
.logo-mark {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.auth-logo .name { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.auth-title { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.auth-sub { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 24px; }

.auth-divider {
  text-align: center; color: var(--text-muted); font-size: 0.8rem;
  margin: 20px 0; position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: ''; position: absolute; top: 50%; width: 42%; height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-footer { text-align: center; font-size: 0.82rem; color: var(--text-muted); margin-top: 16px; }
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { color: var(--accent); }

/* Auth alerts */
.alert-error   { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #ef4444; border-radius: 8px; padding: 10px 14px; font-size: 0.82rem; margin-bottom: 14px; display: none; }
.alert-warning { background: rgba(234,179,8,0.1); border: 1px solid rgba(234,179,8,0.3); color: #eab308; border-radius: 8px; padding: 10px 14px; font-size: 0.82rem; margin-bottom: 14px; display: none; }
.alert-error.show, .alert-warning.show { display: block; }

/* Auth form specifics */
.req { color: var(--accent); }
.btn-full { width: 100%; justify-content: center; }
.mt-16 { margin-top: 16px; }

/* Success step */
#stepSuccess { text-align: center; padding: 20px 0; }
#stepSuccess .success-icon { font-size: 3rem; margin-bottom: 16px; }

/* ── AUTOMATIONS ─────────────────────────────── */
.auto-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s, transform 0.15s;
}
.auto-card:hover { border-color: var(--purple-500); transform: translateY(-2px); }
.auto-card-icon { font-size: 2rem; }
.auto-card-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.auto-card-desc { font-size: 0.82rem; color: var(--text-muted); flex: 1; line-height: 1.5; }
.auto-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border); border-radius: 24px; transition: 0.3s;
}
.toggle-slider:before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--purple-600); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ── CRM DASHBOARD ───────────────────────────── */
.crm-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .crm-kpi-row { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 600px) { .crm-kpi-row { grid-template-columns: repeat(2,1fr); } }

.crm-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}
.crm-kpi-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.crm-kpi-value { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.crm-kpi-value.green { color: var(--green); }
.crm-kpi-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }

.crm-main-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .crm-main-row { grid-template-columns: 1fr; } }

.crm-charts-col { display: flex; flex-direction: column; gap: 0; }
.crm-feed-col { display: flex; flex-direction: column; }

.crm-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 700px) { .crm-bottom-row { grid-template-columns: 1fr; } }

/* Lead feed items */
.lead-feed-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.lead-feed-item:hover { background: var(--bg-secondary); }
.lead-feed-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--purple-600); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.lead-feed-info { flex: 1; min-width: 0; }
.lead-feed-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-feed-meta { font-size: 0.72rem; color: var(--text-muted); }
.lead-feed-time { font-size: 0.7rem; color: var(--text-muted); flex-shrink: 0; }

/* Mini calendar */
.mini-cal { width: 100%; border-collapse: collapse; }
.mini-cal th { font-size: 0.7rem; color: var(--text-muted); padding: 4px; text-align: center; }
.mini-cal td { font-size: 0.78rem; padding: 5px; text-align: center; border-radius: 6px; cursor: default; }
.mini-cal td.today { background: var(--purple-600); color: #fff; font-weight: 700; border-radius: 50%; }
.mini-cal td.has-event { background: rgba(139,92,246,0.15); color: var(--purple-300); font-weight: 600; cursor: pointer; }
.mini-cal td.has-event:hover { background: rgba(139,92,246,0.3); }
.mini-cal td.other-month { opacity: 0.3; }

/* ══════════════════════════════════════════════════
   SCALEPILOT OS — Extended Styles
   Sidebar groups, new sections, command palette,
   notifications, AI systems, infrastructure, CRM
   ══════════════════════════════════════════════════ */

/* ── Sidebar Groups (collapsible) ──────────────── */
.nav-group { margin-bottom: 2px; }
.nav-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 6px; cursor: pointer; user-select: none;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.nav-group-header:hover { background: var(--bg-card); }
.nav-group-label {
  font-size: 0.62rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.09em;
}
.nav-group-chevron {
  width: 14px; height: 14px; color: var(--text-muted);
  transition: transform 0.22s ease; flex-shrink: 0;
}
.nav-group.collapsed .nav-group-chevron { transform: rotate(-90deg); }
.nav-group-items { overflow: hidden; transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1); }
.nav-group.collapsed .nav-group-items { max-height: 0 !important; }
.nav-sub {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 22px;
  border-radius: var(--radius-xs); font-size: 0.82rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: var(--transition);
  border: none; background: none; width: 100%; text-align: left;
  font-family: inherit; position: relative;
}
.nav-sub:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-sub.active { background: rgba(0,201,167,0.10); color: var(--accent); }
.nav-sub.active::before {
  content: ''; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 2px; border-radius: 2px; background: var(--accent);
}
.nav-sub-icon { font-size: 0.88rem; width: 16px; text-align: center; flex-shrink: 0; }
.nav-sub-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 0.6rem; font-weight: 700; padding: 1px 5px;
  border-radius: 20px; min-width: 16px; text-align: center;
}
.nav-divider { height: 1px; background: var(--border); margin: 8px 10px; }

/* ── Topbar — notifications + search ───────────── */
.topbar-search-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text-muted);
  font-size: 0.78rem; cursor: pointer; transition: var(--transition);
  font-family: inherit;
}
.topbar-search-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.topbar-search-btn kbd {
  background: rgba(255,255,255,0.07); border-radius: 4px;
  padding: 1px 5px; font-size: 0.68rem; font-family: inherit;
}
.notif-btn {
  position: relative; width: 36px; height: 36px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xs); display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: var(--transition);
  color: var(--text-secondary);
}
.notif-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.notif-dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-secondary);
}

/* ── Command Palette ────────────────────────────── */
.cmd-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px); z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 18vh; opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
.cmd-overlay.open { opacity: 1; pointer-events: all; }
.cmd-box {
  background: #161616; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,201,167,0.1);
  overflow: hidden; transform: translateY(-8px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16,1,0.3,1);
}
.cmd-overlay.open .cmd-box { transform: translateY(0) scale(1); }
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.cmd-input-icon { color: var(--text-muted); flex-shrink: 0; }
.cmd-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 1rem; color: var(--text-primary); font-family: inherit;
}
.cmd-input::placeholder { color: var(--text-muted); }
.cmd-esc {
  font-size: 0.7rem; color: var(--text-muted); background: rgba(255,255,255,0.07);
  padding: 2px 7px; border-radius: 5px; flex-shrink: 0; font-family: inherit;
}
.cmd-results { max-height: 360px; overflow-y: auto; padding: 6px; }
.cmd-section-label {
  font-size: 0.65rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 10px 12px 5px;
}
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 9px; cursor: pointer;
  transition: var(--transition); border: none; background: none;
  width: 100%; text-align: left; font-family: inherit;
}
.cmd-item:hover, .cmd-item.selected { background: var(--bg-card-hover); }
.cmd-item-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(0,201,167,0.12); border: 1px solid rgba(0,201,167,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; flex-shrink: 0;
}
.cmd-item-text { font-size: 0.88rem; color: var(--text-primary); font-weight: 500; }
.cmd-item-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
.cmd-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 16px; align-items: center;
}
.cmd-hint { display: flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--text-muted); }
.cmd-hint kbd { background: rgba(255,255,255,0.07); border-radius: 4px; padding: 1px 5px; font-family: inherit; }

/* ── OS Stats (expanded dashboard) ─────────────── */
.os-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; margin-bottom: 24px; }
.os-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  transition: var(--transition); position: relative; overflow: hidden;
}
.os-stat::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px; background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0; transition: opacity 0.25s;
}
.os-stat:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.os-stat:hover::after { opacity: 1; }
.os-stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 8px; }
.os-stat-value { font-size: 1.45rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.os-stat-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 5px; }
.os-stat-icon { font-size: 1.2rem; margin-bottom: 10px; opacity: 0.85; }
.os-stat-green .os-stat-value { color: var(--green); }
.os-stat-yellow .os-stat-value { color: var(--yellow); }
.os-stat-blue .os-stat-value { color: var(--blue); }
.os-stat-red .os-stat-value { color: var(--red); }

/* ── Quick Actions Bar ──────────────────────────── */
.quick-actions {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px;
}
.qa-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); font-family: inherit;
}
.qa-btn:hover { border-color: var(--border-hover); color: var(--accent); background: var(--accent-dim); }

/* ── Section header strip ───────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px;
}
.section-heading {
  font-size: 1.25rem; font-weight: 800;
  color: var(--text-primary); letter-spacing: -0.01em; line-height: 1.3;
}
.section-heading span { color: var(--accent); }

/* ── Kanban Board ───────────────────────────────── */
.kanban-board {
  display: flex; gap: 16px; align-items: start;
  overflow-x: auto; padding-bottom: 12px;
}
.kanban-col { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex: 0 0 270px; min-width: 270px; }
.kanban-col-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.kanban-col-title { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.kanban-col-count { background: rgba(255,255,255,0.08); color: var(--text-muted); font-size: 0.7rem; padding: 2px 7px; border-radius: 20px; }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px 14px; cursor: pointer;
  transition: var(--transition);
}
.kanban-card:hover { border-color: var(--border-hover); background: rgba(255,255,255,0.07); transform: translateY(-1px); }
.kanban-card-title { font-size: 0.83rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.kanban-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kanban-card-tag {
  font-size: 0.68rem; padding: 2px 7px; border-radius: 20px;
  font-weight: 600;
}
.kanban-card-tag.green { background: rgba(0,201,167,0.12); color: var(--green); }
.kanban-card-tag.yellow { background: rgba(234,179,8,0.12); color: var(--yellow); }
.kanban-card-tag.blue { background: rgba(59,130,246,0.12); color: var(--blue); }
.kanban-card-tag.red { background: rgba(239,68,68,0.12); color: var(--red); }
.kanban-card-tag.gray { background: rgba(255,255,255,0.07); color: var(--text-muted); }
.kanban-add-btn {
  margin: 8px; padding: 8px 12px; border-radius: 8px;
  border: 1px dashed rgba(255,255,255,0.1); background: none;
  color: var(--text-muted); font-size: 0.8rem; cursor: pointer;
  width: calc(100% - 16px); text-align: left; transition: var(--transition);
  font-family: inherit;
}
.kanban-add-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Agent Cards (AI Systems) ───────────────────── */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.agent-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; transition: var(--transition);
  position: relative; overflow: hidden;
}
.agent-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: linear-gradient(90deg, var(--accent), rgba(0,201,167,0));
  opacity: 0; transition: opacity 0.25s;
}
.agent-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.agent-card:hover::before { opacity: 1; }
.agent-card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.agent-card-icon {
  width: 42px; height: 42px; border-radius: 11px;
  background: rgba(0,201,167,0.12); border: 1px solid rgba(0,201,167,0.15);
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.agent-status-badge {
  font-size: 0.68rem; font-weight: 700; padding: 3px 9px;
  border-radius: 20px;
}
.agent-status-badge.active { background: rgba(0,201,167,0.12); color: var(--green); border: 1px solid rgba(0,201,167,0.2); }
.agent-status-badge.paused { background: rgba(234,179,8,0.12); color: var(--yellow); border: 1px solid rgba(234,179,8,0.2); }
.agent-status-badge.offline { background: rgba(239,68,68,0.10); color: var(--red); border: 1px solid rgba(239,68,68,0.18); }
.agent-card-name { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.agent-card-client { font-size: 0.77rem; color: var(--text-muted); margin-bottom: 14px; }
.agent-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.agent-stat { background: rgba(255,255,255,0.04); border-radius: 8px; padding: 10px 12px; }
.agent-stat-label { font-size: 0.68rem; color: var(--text-muted); margin-bottom: 3px; }
.agent-stat-val { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.agent-card-footer { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.agent-type-pill {
  font-size: 0.68rem; font-weight: 600; padding: 3px 9px;
  border-radius: 20px; background: rgba(59,130,246,0.1); color: var(--blue);
  border: 1px solid rgba(59,130,246,0.15);
}

/* ── Infrastructure ─────────────────────────────── */
.infra-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }
.infra-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; transition: var(--transition);
}
.infra-card:hover { border-color: var(--border-hover); }
.infra-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.infra-card-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: rgba(0,201,167,0.1); display: flex; align-items: center;
  justify-content: center; font-size: 1rem;
}
.infra-card-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.infra-card-ip { font-size: 0.72rem; color: var(--text-muted); }
.health-indicator {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  margin-left: auto;
}
.health-indicator.online { background: var(--green); box-shadow: 0 0 8px rgba(0,201,167,0.6); animation: healthPulse 2s ease-in-out infinite; }
.health-indicator.warning { background: var(--yellow); }
.health-indicator.offline { background: var(--red); }
@keyframes healthPulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.resource-bar { margin-bottom: 10px; }
.resource-bar-header { display: flex; justify-content: space-between; margin-bottom: 5px; }
.resource-bar-label { font-size: 0.72rem; color: var(--text-muted); }
.resource-bar-val { font-size: 0.72rem; font-weight: 600; color: var(--text-primary); }
.resource-track {
  height: 5px; background: rgba(255,255,255,0.07); border-radius: 3px; overflow: hidden;
}
.resource-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
}
.resource-fill.warn { background: linear-gradient(90deg, var(--yellow), #ca8a04); }
.resource-fill.danger { background: linear-gradient(90deg, var(--red), #b91c1c); }

/* ── Clients ────────────────────────────────────── */
.clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.client-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; transition: var(--transition);
  cursor: pointer;
}
.client-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); transform: translateY(-2px); }
.client-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.client-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: #000; flex-shrink: 0;
}
.client-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.client-company { font-size: 0.75rem; color: var(--text-muted); }
.client-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.client-stat { text-align: center; background: rgba(255,255,255,0.04); border-radius: 8px; padding: 8px 6px; }
.client-stat-val { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.client-stat-label { font-size: 0.65rem; color: var(--text-muted); }
.client-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── Reports ────────────────────────────────────── */
.reports-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .reports-grid { grid-template-columns: 1fr; } }
.report-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.report-card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.report-card-title { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.chart-wrap { padding: 16px; height: 220px; }

/* ── Team ───────────────────────────────────────── */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.team-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; transition: var(--transition); text-align: center;
}
.team-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.team-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; color: #000;
  margin: 0 auto 12px; border: 2px solid rgba(0,201,167,0.25);
}
.team-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.team-role-pill {
  display: inline-block; font-size: 0.68rem; font-weight: 600;
  padding: 3px 10px; border-radius: 20px; margin-bottom: 14px;
}
.team-role-pill.admin { background: rgba(0,201,167,0.12); color: var(--green); }
.team-role-pill.team { background: rgba(59,130,246,0.12); color: var(--blue); }
.team-role-pill.client { background: rgba(234,179,8,0.12); color: var(--yellow); }
.team-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.team-stat { background: rgba(255,255,255,0.04); border-radius: 8px; padding: 8px; }
.team-stat-val { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.team-stat-label { font-size: 0.65rem; color: var(--text-muted); }

/* ── Activity Feed ──────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border); align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  margin-top: 5px; background: var(--accent);
}
.activity-dot.yellow { background: var(--yellow); }
.activity-dot.blue { background: var(--blue); }
.activity-dot.red { background: var(--red); }
.activity-text { font-size: 0.82rem; color: var(--text-primary); line-height: 1.5; }
.activity-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Notification Drawer ────────────────────────── */
.notif-drawer {
  position: fixed; top: 60px; right: 20px; width: 340px;
  background: #161616; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; z-index: 500;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  opacity: 0; transform: translateY(-8px) scale(0.97);
  pointer-events: none; transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
  max-height: 70vh; display: flex; flex-direction: column;
}
.notif-drawer.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }
.notif-drawer-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.notif-drawer-title { font-size: 0.88rem; font-weight: 700; color: var(--text-primary); }
.notif-mark-all { font-size: 0.75rem; color: var(--accent); cursor: pointer; background: none; border: none; font-family: inherit; }
.notif-list { overflow-y: auto; padding: 8px; flex: 1; }
.notif-item {
  display: flex; gap: 10px; padding: 10px; border-radius: 9px;
  cursor: pointer; transition: var(--transition); align-items: flex-start;
}
.notif-item:hover { background: var(--bg-card); }
.notif-item.unread { background: rgba(0,201,167,0.05); }
.notif-icon { font-size: 1.1rem; flex-shrink: 0; width: 28px; text-align: center; }
.notif-body { flex: 1; }
.notif-body-text { font-size: 0.8rem; color: var(--text-primary); line-height: 1.5; }
.notif-body-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.notif-unread-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 5px; }

/* ── Pipeline CRM ───────────────────────────────── */
.pipeline-board {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px;
}
.pipeline-col {
  flex-shrink: 0; width: 240px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.pipeline-col-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.pipeline-col-name { font-size: 0.8rem; font-weight: 700; color: var(--text-primary); }
.pipeline-col-val { font-size: 0.72rem; color: var(--green); font-weight: 600; }
.pipeline-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.pipeline-card {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 9px; padding: 11px 12px; cursor: grab; transition: var(--transition);
}
.pipeline-card:hover { border-color: rgba(0,201,167,0.3); }
.pipeline-card-name { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; }
.pipeline-card-detail { font-size: 0.72rem; color: var(--text-muted); }
.pipeline-card-amount { font-size: 0.82rem; font-weight: 700; color: var(--green); margin-top: 6px; }

/* ── Responsive additions ───────────────────────── */
@media (max-width: 900px) {
  .os-stats { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { gap: 10px; }
  .kanban-col { flex: 0 0 240px; min-width: 240px; }
  .agent-grid { grid-template-columns: 1fr; }
  .clients-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .os-stats { grid-template-columns: 1fr 1fr; }
  .team-grid { grid-template-columns: 1fr; }
}

/* ── Responsive overrides ───────────────────────── */
@media (max-width: 800px) {
  .dash-2col { grid-template-columns: 1fr !important; }
  .topbar-search-btn { display: none; }
  .quick-actions { gap: 6px; }
  .qa-btn { font-size: 0.76rem; padding: 7px 10px; }
  .section-heading { font-size: 1rem; }
  .pipeline-board { gap: 10px; }
  .pipeline-col { width: 200px; }
}

/* ── Sidebar logo ───────────────────────────────── */
.sidebar-logo svg { display: block; }

/* ── OS branding sub-label ──────────────────────── */
.sidebar-brand span { color: var(--accent); font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.8; }

/* ── Agent card border on hover ─────────────────── */
.agent-card:hover { box-shadow: 0 0 0 1px rgba(0,201,167,0.2), 0 8px 24px rgba(0,0,0,0.3); }

/* ── Kanban col status dots ─────────────────────── */
.kanban-col-header { background: rgba(255,255,255,0.02); }

/* ── Infra card hover glow ──────────────────────── */
.infra-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.3); }

/* ── Section fade-in ────────────────────────────── */
.portal-section.active {
  animation: sectionFadeIn 0.22s cubic-bezier(0.16,1,0.3,1);
}
@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Nav group items overflow fix ───────────────── */
.nav-group-items { overflow: hidden; }

/* ── Pipeline board scroll ──────────────────────── */
.kanban-board::-webkit-scrollbar, .pipeline-board::-webkit-scrollbar { height: 4px; }
.kanban-board::-webkit-scrollbar-track, .pipeline-board::-webkit-scrollbar-track { background: transparent; }
.kanban-board::-webkit-scrollbar-thumb, .pipeline-board::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Layout fixes ─────────────────────────────────── */
.modal { max-height: 90vh; overflow-y: auto; }
.dash-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 860px) {
  .dash-2col { grid-template-columns: 1fr !important; }
}
.os-stat-icon { font-size: 1.1rem; margin-bottom: 8px; opacity: 0.85; }
/* Section top gap so content doesn't hug topbar */
.page-content > .portal-section:first-child { margin-top: 0; }
/* Agents grid on new sections */
.section-agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap:16px; }


/* ================================================================
   PORTAL MOBILE RESPONSIVE FIXES
   ================================================================ */

@media (max-width: 768px) {
  /* Tables - always scrollable horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
  .data-table { min-width: 560px; }

  /* Panel headers with search inputs - wrap to two lines */
  .panel-header { flex-wrap: wrap; gap: 8px; }
  .panel-header .form-control { max-width: 100% !important; width: 100% !important; }

  /* Section headers - allow wrap so button drops below heading */
  .section-header { flex-wrap: wrap; gap: 10px; }

  /* OS stats strip - 3 columns on tablet */
  .os-stats { grid-template-columns: repeat(3, 1fr) !important; gap: 10px; }

  /* Quick actions - wrap 3 per row */
  .quick-actions { grid-template-columns: repeat(3, 1fr); }

  /* Topbar adjustments */
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-right { gap: 8px; }
  #topbarSearch { display: none; }

  /* Finance summary - 2 columns */
  .finance-summary { grid-template-columns: 1fr 1fr; }

  /* Modals - slide up from bottom, full width */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    width: 100% !important; max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 88vh; overflow-y: auto;
  }

  /* Tab bar - scrollable horizontal */
  .tab-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 6px; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; }

  /* Dash 2col - stack */
  .dash-2col { grid-template-columns: 1fr !important; }

  /* Reports grid - 1 column */
  .reports-grid { grid-template-columns: 1fr !important; }

  /* Agent/infra grids - 1 column */
  .agent-grid { grid-template-columns: 1fr !important; }
  .infra-grid { grid-template-columns: 1fr !important; }

  /* Clients grid */
  .clients-grid { grid-template-columns: 1fr !important; }

  /* Team grid */
  .team-grid { grid-template-columns: 1fr 1fr !important; }

  /* Pipeline/kanban boards - horizontal scroll (already flex) */
  .pipeline-board { gap: 10px; }
  .pipeline-col { flex: 0 0 220px !important; min-width: 220px !important; }
  .kanban-col { flex: 0 0 230px !important; min-width: 230px !important; }

  /* Form rows */
  .form-row { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  /* OS stats - 2 columns on small phones */
  .os-stats { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .os-stat { padding: 12px 10px; }
  .os-stat-value { font-size: 1.15rem; }
  .os-stat-label { font-size: 0.67rem; }

  /* Quick actions - 2 per row */
  .quick-actions { grid-template-columns: 1fr 1fr !important; gap: 6px; }
  .qa-btn { font-size: 0.75rem !important; padding: 9px 8px !important; }

  /* Page content padding */
  .page-content { padding: 14px !important; }

  /* Topbar */
  .topbar { padding: 0 12px; min-height: 54px; }
  #topbarTitle { font-size: 0.9rem; }

  /* Section heading smaller */
  .section-heading { font-size: 0.95rem; }

  /* Team grid - 1 column */
  .team-grid { grid-template-columns: 1fr !important; }

  /* Finance summary - 2 per row */
  .finance-summary { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .fc-value { font-size: 1.3rem; }

  /* Kanban/pipeline columns narrower */
  .kanban-col  { flex: 0 0 200px !important; min-width: 200px !important; }
  .pipeline-col { flex: 0 0 190px !important; min-width: 190px !important; }

  /* Modals */
  .modal { max-height: 92vh; }
  .modal-title { font-size: 1rem; }

  /* Subscriptions KPI strip */
  #subsKpiStrip { grid-template-columns: 1fr 1fr !important; }
}

/* ══════════════════════════════════════════════
   PORTAL CARD SCALE-IN ANIMATIONS
   ══════════════════════════════════════════════ */
@keyframes cardScaleIn {
  from { opacity: 0; transform: scale(0); }
  to   { opacity: 1; transform: scale(1); }
}

/* Dashboard OS stats strip */
.portal-section.active .os-stats .os-stat {
  animation: cardScaleIn 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}
.portal-section.active .os-stats .os-stat:nth-child(1)  { animation-delay: 0.03s; }
.portal-section.active .os-stats .os-stat:nth-child(2)  { animation-delay: 0.09s; }
.portal-section.active .os-stats .os-stat:nth-child(3)  { animation-delay: 0.15s; }
.portal-section.active .os-stats .os-stat:nth-child(4)  { animation-delay: 0.21s; }
.portal-section.active .os-stats .os-stat:nth-child(5)  { animation-delay: 0.27s; }
.portal-section.active .os-stats .os-stat:nth-child(6)  { animation-delay: 0.33s; }
.portal-section.active .os-stats .os-stat:nth-child(7)  { animation-delay: 0.39s; }
.portal-section.active .os-stats .os-stat:nth-child(8)  { animation-delay: 0.45s; }
.portal-section.active .os-stats .os-stat:nth-child(9)  { animation-delay: 0.51s; }
.portal-section.active .os-stats .os-stat:nth-child(10) { animation-delay: 0.57s; }
.portal-section.active .os-stats .os-stat:nth-child(11) { animation-delay: 0.63s; }
.portal-section.active .os-stats .os-stat:nth-child(12) { animation-delay: 0.69s; }

/* Admin stats grid */
.portal-section.active .stats-grid .stat-card {
  animation: cardScaleIn 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}
.portal-section.active .stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.portal-section.active .stats-grid .stat-card:nth-child(2) { animation-delay: 0.15s; }
.portal-section.active .stats-grid .stat-card:nth-child(3) { animation-delay: 0.25s; }
.portal-section.active .stats-grid .stat-card:nth-child(4) { animation-delay: 0.35s; }
.portal-section.active .stats-grid .stat-card:nth-child(5) { animation-delay: 0.45s; }
.portal-section.active .stats-grid .stat-card:nth-child(6) { animation-delay: 0.55s; }

/* Automation template cards */
.portal-section.active .auto-card {
  animation: cardScaleIn 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}
.portal-section.active .tab-pane .auto-card:nth-child(1) { animation-delay: 0.05s; }
.portal-section.active .tab-pane .auto-card:nth-child(2) { animation-delay: 0.15s; }
.portal-section.active .tab-pane .auto-card:nth-child(3) { animation-delay: 0.25s; }
.portal-section.active .tab-pane .auto-card:nth-child(4) { animation-delay: 0.35s; }
.portal-section.active .tab-pane .auto-card:nth-child(5) { animation-delay: 0.45s; }
.portal-section.active .tab-pane .auto-card:nth-child(6) { animation-delay: 0.55s; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .portal-section.active .os-stat,
  .portal-section.active .stat-card,
  .portal-section.active .auto-card {
    animation: none !important; opacity: 1 !important; transform: none !important;
  }
}
ard {
    animation: none !important; opacity: 1 !important; transform: none !important;
  }
}

/* ── DEMO HUB ────────────────────────────────────── */
.demo-hub-card { overflow:hidden; transition:transform .2s, box-shadow .2s; }
.demo-hub-card:hover { transform:translateY(-2px); box-shadow:0 8px 32px rgba(0,0,0,.3); }

.demo-hub-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px; border-bottom:1px solid var(--border);
  background:rgba(255,255,255,.02);
}
.demo-hub-icon {
  width:40px; height:40px; border-radius:10px;
  background:rgba(0,201,167,.1); border:1px solid rgba(0,201,167,.2);
  display:flex; align-items:center; justify-content:center; font-size:1.2rem;
}
.demo-hub-name { font-size:.9rem; font-weight:600; color:var(--text); }
.demo-hub-sub  { font-size:.72rem; color:var(--text-muted); margin-top:2px; }

.demo-hub-live-badge {
  display:flex; align-items:center; gap:6px;
  background:rgba(0,201,167,.1); border:1px solid rgba(0,201,167,.25);
  border-radius:20px; padding:4px 10px;
  font-size:.68rem; font-weight:600; color:var(--green);
}
.demo-hub-coming-badge {
  background:rgba(255,255,255,.06); border:1px solid var(--border);
  border-radius:20px; padding:4px 10px;
  font-size:.68rem; font-weight:600; color:var(--text-muted);
}

.demo-hub-body { padding:16px 20px; }
.demo-hub-info-row {
  display:flex; justify-content:space-between; align-items:center;
  padding:6px 0; border-bottom:1px solid rgba(255,255,255,.04); font-size:.78rem;
}
.demo-hub-info-row:last-of-type { border-bottom:none; }
.demo-hub-label { color:var(--text-muted); font-size:.72rem; }
.demo-hub-value { color:var(--text); font-weight:500; }

.demo-hub-chip {
  background:rgba(255,255,255,.05); border:1px solid var(--border);
  border-radius:20px; padding:3px 9px; font-size:.68rem; color:var(--text-muted);
}

.demo-hub-footer {
  display:flex; gap:8px; padding:14px 20px;
  border-top:1px solid var(--border); background:rgba(255,255,255,.02);
}

.pdemo-dot {
  width:7px; height:7px; border-radius:50%;
  background:var(--green); display:inline-block;
  animation:pulse 1.8s ease-in-out infinite;
}
