

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

:root {
  --accent: #185FA5;
  --accent-light: #e8f0fa;
  --bg: #f5f5f7;
  --white: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #3a3a3c;
  --text-muted: #86868b;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.12);
  --green: #34c759;
  --green-bg: #ecfdf3;
  --green-text: #15803d;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --amber-text: #92400e;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --red-text: #991b1b;
  --blue-bg: #eff6ff;
  --blue-text: #1e40af;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', system-ui, sans-serif;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}


.app-layout {
  display: flex;
  min-height: 100vh;
}


.sidebar {
  width: 260px;
  background: var(--white);
  border-right: 0.5px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px 20px;
}
.sidebar-logo .logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.3px;
}
.sidebar-logo .logo-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}
.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--bg);
}
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.4;
}
.nav-item .nav-icon svg {
  width: 18px;
  height: 18px;
}
.nav-item.active .nav-icon {
  opacity: 1;
}
.nav-item[data-tab="stripe"] .nav-icon,
.nav-item[data-tab="attom"] .nav-icon {
  opacity: 1;
}
.nav-item .nav-icon img {
  width: 18px;
  height: 18px;
  display: block;
}
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.user-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text-muted);
}
.sidebar-user .btn-logout {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}
.sidebar-user .btn-logout:hover {
  color: var(--red);
}

.main-content {
  flex: 1;
  margin-left: 260px;
}

.top-bar {
  background: var(--white);
  border-bottom: 0.5px solid var(--border-strong);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 28px 32px;
}


.search-input {
  padding: 8px 14px;
  border: 0.5px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  width: 260px;
  transition: border-color 0.15s;
  font-family: inherit;
}
.search-input:focus {
  border-color: var(--accent);
  background: var(--white);
}
.search-input::placeholder {
  color: var(--text-muted);
}





.btn {
  padding: 7px 16px;
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  background: var(--white);
  color: var(--text-secondary);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: #14508c; }
.btn-danger { background: var(--white); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-success { background: var(--white); color: var(--green-text); border-color: var(--green); }
.btn-success:hover { background: var(--green-bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }




.stats-row {
  display: flex;
  align-items: baseline;
  gap: 0;
  margin-bottom: 32px;
}
.stat-item {
  flex: 1;
  padding: 0 24px;
  border-right: 0.5px solid var(--border-strong);
}
.stat-item:first-child { padding-left: 0; }
.stat-item:last-child { border-right: none; }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.stat-sub {
  font-size: 12px;
  color: var(--accent);
  margin-top: 2px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border-strong);
}
.data-table td {
  padding: 12px;
  border-bottom: 0.5px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
.data-table tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover { background: rgba(0,0,0,0.02); }
.data-table .cell-name {
  font-weight: 600;
  color: var(--text-primary);
}
.data-table .cell-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}
.data-table .cell-link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.data-table .cell-right {
  text-align: right;
}
.data-table .cell-value {
  font-weight: 600;
  color: var(--accent);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-approved, .badge-active, .badge-closed_won, .badge-agreement_signed, .badge-listed, .badge-converted {
  background: var(--green-bg); color: var(--green-text);
}
.badge-pending, .badge-pending_agreement, .badge-active_nurture, .badge-under_contract {
  background: var(--amber-bg); color: var(--amber-text);
}
.badge-rejected, .badge-closed_lost, .badge-invalid {
  background: var(--red-bg); color: var(--red-text);
}
.badge-new, .badge-routed, .badge-alert_sent, .badge-claimed {
  background: var(--blue-bg); color: var(--blue-text);
}
.badge-appointment_scheduled, .badge-appointment_completed, .badge-attempted_contact {
  background: #f3f4f6; color: var(--text-secondary);
}
.badge-reassigned {
  background: #f3f4f6; color: var(--text-muted);
}
.badge-hot { background: var(--red-bg); color: var(--red-text); }
.badge-warm { background: var(--amber-bg); color: var(--amber-text); }
.badge-cold { background: var(--blue-bg); color: var(--blue-text); }
.badge-unclaimed { background: #fef3cd; color: #856404; }
.badge-unassigned { background: var(--bg); color: var(--text-muted); }
.badge-appointment { background: #d4edda; color: #155724; }
.badge-unpaid { background: #fef3cd; color: #856404; }
.badge-paid    { background: #d4edda; color: #155724; }
.badge-sms-qualified { background: var(--blue-bg); color: var(--blue-text); }
.badge-asap          { background: var(--red-bg); color: var(--red-text); }

.chat-container {
  background: #ffffff;
  border-radius: 16px;
  border: 0.5px solid var(--border-strong);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
}
.chat-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: flex-start;
}
.chat-left { justify-content: flex-start; }
.chat-right { justify-content: flex-end; }
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e8e8ed;
  color: #6e6e73;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-avatar-ai {
  background: var(--accent);
  color: white;
}
.chat-sender {
  font-size: 11px;
  color: #6e6e73;
  font-weight: 500;
  margin-bottom: 3px;
  padding: 0 4px;
}
.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 380px;
  word-wrap: break-word;
}
.chat-bubble-left {
  background: #f2f2f7;
  color: #1d1d1f;
  border-top-left-radius: 4px;
}
.chat-bubble-right {
  background: var(--accent);
  color: white;
  border-top-right-radius: 4px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.toolbar select {
  padding: 8px 12px;
  border: 0.5px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  outline: none;
  font-family: inherit;
  cursor: pointer;
}
.toolbar select:focus { border-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.visible { display: block; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  background: var(--white);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
}

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
}

.login-container {
  max-width: 380px;
  margin: 120px auto;
  padding: 40px;
  text-align: center;
}
.login-container h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.3px;
}
.login-container .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}
.login-links {
  margin-top: 20px;
  font-size: 13px;
}
.login-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.login-links a:hover { text-decoration: underline; }

.profile-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
.profile-main { min-width: 0; }
.profile-sidebar { min-width: 0; }

.profile-header {
  padding: 0 0 20px;
  margin-bottom: 20px;
  border-bottom: 0.5px solid var(--border-strong);
}
.profile-header h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.profile-header .profile-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.profile-header .profile-status {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.profile-section {
  margin-bottom: 28px;
}
.profile-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--border);
}
.profile-section:empty { display: none; }

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.profile-field { font-size: 14px; }
.profile-field .field-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.profile-field .field-value {
  color: var(--text-primary);
  font-weight: 600;
}

.note-item {
  padding: 12px 0;
  border-bottom: 0.5px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.note-content {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: 8px;
  background: var(--red, #e63946);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
}

.notif-item {
  position: relative;
  padding: 14px 16px;
  border: 0.5px solid var(--border-strong);
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s;
  background: var(--surface, white);
}
.notif-item:hover { background: var(--bg); }
.notif-unread { border-left: 3px solid var(--accent); }
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.notif-subject { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.notif-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.notif-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
}
.notif-unread-dot {
  position: absolute;
  top: 16px;
  right: 12px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

/* Internal Activity Log */
.activity-log { margin-top: 8px; }
.activity-item {
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.activity-actor { font-weight: 600; }
.activity-action {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
}
.note-delete {
  cursor: pointer;
  color: var(--red);
  font-size: 12px;
  opacity: 0.5;
}
.note-delete:hover { opacity: 1; }
.note-form { margin-bottom: 12px; }
.note-form textarea {
  width: 100%;
  padding: 10px;
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
  outline: none;
  font-family: inherit;
  color: var(--text-primary);
}
.note-form textarea:focus { border-color: var(--accent); }
.note-form button { margin-top: 8px; }

/* Agreement card */
.agreement-card {
  padding: 14px 0;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 0;
}
.agreement-card:last-child { border-bottom: none; }
.agreement-card .agreement-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.agreement-card .agreement-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 1px;
}

/* Sidebar items */
.sidebar-item {
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: opacity 0.1s;
}
.sidebar-item:last-child { border-bottom: none; }
.sidebar-item:hover { opacity: 0.7; }
.sidebar-item .sidebar-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.sidebar-item .sidebar-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ══ Detail Panel (Referral) ══ */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  height: 100vh;
  background: var(--white);
  border-left: 0.5px solid var(--border-strong);
  overflow-y: auto;
  z-index: 200;
  padding: 24px;
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 0.5px solid var(--border);
}
.detail-header h3 {
  font-size: 17px;
  font-weight: 600;
}
.detail-section {
  margin-bottom: 24px;
}
.detail-section h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 0.5px solid var(--border);
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}
.detail-row .label {
  color: var(--text-muted);
  font-size: 13px;
}
.detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.15);
  z-index: 199;
}

/* Timeline */
.timeline { padding-left: 0; }
.timeline-item {
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.timeline-text { font-size: 13px; }

/* Signature */
.signature-container {
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  position: relative;
}
.signature-container canvas {
  display: block;
  width: 100%;
  height: 150px;
  cursor: crosshair;
}
.signature-clear {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

/* ══ Modal ══ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--white);
  border-radius: 12px;
  padding: 28px;
  max-width: 440px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
}
.modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}
.modal-body textarea, .modal-body input:not([type="checkbox"]):not([type="radio"]), .modal-body select {
  width: 100%;
  padding: 8px 12px;
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  font-size: 14px;
  margin-top: 8px;
  outline: none;
  font-family: inherit;
  color: var(--text-primary);
}
.modal-body textarea:focus, .modal-body input:not([type="checkbox"]):not([type="radio"]):focus { border-color: var(--accent); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ══ Empty state ══ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ══ Responsive ══ */
@media (max-width: 1024px) {
  .profile-layout { grid-template-columns: 1fr; }
}
.mobile-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0.5px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.mobile-nav-toggle:hover { background: var(--bg); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 99;
  animation: backdropFade 0.2s ease;
}
@keyframes backdropFade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 24px rgba(0,0,0,0.18); }
  .main-content { margin-left: 0; }
  .top-bar { padding: 0 16px; gap: 10px; }
  .top-bar h1 { font-size: 16px; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-content { padding: 18px 16px; }
  .mobile-nav-toggle { display: inline-flex; }
  .sidebar-backdrop.open { display: block; }
  .stats-row { flex-wrap: wrap; }
  .stat-item { min-width: 120px; margin-bottom: 12px; }
  .detail-panel { width: 100%; }
  .login-container { margin: 48px auto; padding: 28px 20px; max-width: 100%; }
  .login-container h1 { font-size: 22px; }
  .login-container .subtitle { margin-bottom: 24px; }
  .modal-box { padding: 22px 18px; max-width: calc(100vw - 24px); }
  .modal-title { font-size: 16px; }
}
