/* ============================================================
   PowerSales CRM — Midnight OS Design System
   ============================================================ */

/* FONTS & RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surfaces */
  --surface-base:    #0e0e0e;
  --surface-1:       #131313;
  --surface-2:       #191919;
  --surface-3:       #1f1f1f;
  --surface-4:       #262626;
  --surface-5:       #2e2e2e;

  /* Brand */
  --primary:         #ba9eff;
  --primary-dim:     #8455ef;
  --primary-glow:    rgba(186, 158, 255, 0.12);
  --primary-border:  rgba(186, 158, 255, 0.25);

  /* Text */
  --text-primary:    #ffffff;
  --text-secondary:  #ababab;
  --text-muted:      #666666;
  --text-inverse:    #0e0e0e;

  /* Status */
  --green:           #4ade80;
  --green-bg:        rgba(74, 222, 128, 0.1);
  --yellow:          #fbbf24;
  --yellow-bg:       rgba(251, 191, 36, 0.1);
  --red:             #f87171;
  --red-bg:          rgba(248, 113, 113, 0.1);
  --blue:            #60a5fa;
  --blue-bg:         rgba(96, 165, 250, 0.1);
  --orange:          #fb923c;
  --orange-bg:       rgba(251, 146, 60, 0.1);

  /* Layout */
  --sidebar-width:   240px;
  --header-height:   64px;
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       14px;
  --radius-xl:       20px;
  --radius-pill:     999px;

  /* Transitions */
  --transition:      0.15s ease;
}

html, body {
  height: 100%;
  background: var(--surface-base);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ============================================================
   AUTH SCREEN
   ============================================================ */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-base);
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(186,158,255,0.08) 0%, transparent 70%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: var(--surface-1);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,0.06);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.auth-logo-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: var(--text-inverse);
}

.auth-logo-text {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.auth-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.auth-sub {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 14px;
}

.auth-error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.btn-link {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: color var(--transition);
}
.btn-link:hover { color: var(--primary); }

/* ============================================================
   APP SHELL
   ============================================================ */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 12px;
  color: var(--text-inverse);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  border-right: 2px solid transparent;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-glow);
  border-right-color: var(--primary);
}

.nav-item .material-symbols-outlined {
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-bottom {
  padding: 8px;
  border-top: 1px solid rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 12px;
  color: var(--text-inverse);
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.sidebar-logout {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.sidebar-logout:hover { color: var(--red); }
.sidebar-logout .material-symbols-outlined { font-size: 18px; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main {
  flex: 1;
  overflow-y: auto;
  background: var(--surface-base);
}

#view-container {
  min-height: 100%;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px 0;
  margin-bottom: 24px;
}

.page-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.4px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   CARDS & SURFACES
   ============================================================ */

.card {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.04);
}

.card-inner {
  padding: 20px;
}

.stat-card {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.04);
  padding: 20px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.5px;
}

.stat-delta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn .material-symbols-outlined { font-size: 16px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  color: var(--text-inverse);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-ghost {
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.06);
}
.btn-ghost:hover { background: var(--surface-4); color: var(--text-primary); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.15);
}
.btn-danger:hover { background: rgba(248,113,113,0.2); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 11px 16px; }

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--surface-4); color: var(--text-primary); }
.btn-icon .material-symbols-outlined { font-size: 17px; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: #000000;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 13.5px;
  transition: border-color var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: rgba(186,158,255,0.4);
  box-shadow: 0 0 0 3px rgba(186,158,255,0.06);
}

.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option { background: var(--surface-2); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

/* ============================================================
   TABLE
   ============================================================ */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-secondary);
}

.table td:first-child { color: var(--text-primary); font-weight: 500; }

.table tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--transition);
  cursor: pointer;
}
.table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-green  { background: var(--green-bg);  color: var(--green);  }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red    { background: var(--red-bg);    color: var(--red);    }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);   }
.badge-purple { background: var(--primary-glow); color: var(--primary); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-muted  { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 32px;
}

.tab {
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  cursor: pointer;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   SEARCH & FILTERS
   ============================================================ */

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar .material-symbols-outlined {
  position: absolute;
  left: 10px;
  font-size: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  padding: 8px 14px 8px 36px;
  font-size: 13px;
  outline: none;
  width: 240px;
  transition: all var(--transition);
}

.search-input:focus {
  border-color: var(--primary-border);
  width: 280px;
}

.search-input::placeholder { color: var(--text-muted); }

.filter-tabs {
  display: flex;
  gap: 4px;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  transition: all var(--transition);
  cursor: pointer;
}

.filter-tab:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }
.filter-tab.active { background: var(--primary-glow); color: var(--primary); }

/* ============================================================
   CLIENT DIRECTORY
   ============================================================ */

.clients-page {
  padding: 0;
}

.clients-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  gap: 16px;
}

.clients-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================================
   CLIENT FILE
   ============================================================ */

.client-file {
  min-height: 100vh;
}

.client-file-hero {
  background: var(--surface-1);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  padding: 28px 32px 0;
}

.client-file-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
  transition: color var(--transition);
  cursor: pointer;
}
.client-file-back:hover { color: var(--text-secondary); }
.client-file-back .material-symbols-outlined { font-size: 16px; }

.client-file-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}

.client-file-name {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.5px;
}

.client-file-biz {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 2px;
  margin-bottom: 16px;
}

.client-file-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.client-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.client-meta-item .material-symbols-outlined { font-size: 15px; color: var(--text-muted); }
.client-meta-item a { color: var(--primary); }
.client-meta-item a:hover { text-decoration: underline; }

/* ============================================================
   OVERVIEW TAB
   ============================================================ */

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  padding: 24px 32px;
}

.overview-left { display: flex; flex-direction: column; gap: 20px; }
.overview-right { display: flex; flex-direction: column; gap: 20px; }

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

.section-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.contract-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
}

.contract-item { display: flex; flex-direction: column; gap: 2px; }
.contract-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.contract-value { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }

.onboarding-list { display: flex; flex-direction: column; gap: 8px; }

.onboarding-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.onboarding-item.done { color: var(--text-muted); text-decoration: line-through; }

.onboarding-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: transparent;
  cursor: pointer;
  appearance: none;
  flex-shrink: 0;
  transition: all var(--transition);
  position: relative;
}

.onboarding-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.onboarding-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: 2px solid var(--text-inverse);
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.activity-feed { display: flex; flex-direction: column; gap: 0; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-icon .material-symbols-outlined { font-size: 14px; color: var(--text-muted); }

.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.log-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  margin-top: 12px;
}

.log-type-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.log-type-btn {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.log-type-btn.active { background: var(--primary-glow); color: var(--primary); }

/* ============================================================
   INVOICES TAB
   ============================================================ */

.invoices-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.invoice-row-recurring {
  position: relative;
}
.invoice-row-recurring::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.invoice-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition);
}
.table tbody tr:hover .invoice-actions { opacity: 1; }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-container {
  background: rgba(19,19,19,0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.modal-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.3px;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-3); color: var(--text-primary); }
.modal-close .material-symbols-outlined { font-size: 18px; }

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ============================================================
   TOAST
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-4);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn 0.2s ease;
  min-width: 240px;
  max-width: 360px;
}

.toast .material-symbols-outlined { font-size: 17px; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--green); }
.toast-success .material-symbols-outlined { color: var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-error .material-symbols-outlined { color: var(--red); }
.toast-info { border-left: 3px solid var(--blue); }
.toast-info .material-symbols-outlined { color: var(--blue); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.empty-state .material-symbols-outlined {
  font-size: 40px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.empty-state-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
}

.empty-state-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ============================================================
   LOADING
   ============================================================ */

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255,255,255,0.08);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   DASHBOARD
   ============================================================ */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 0 32px 24px;
}

.dashboard-section {
  padding: 0 32px 32px;
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-green     { color: var(--green); }
.text-red       { color: var(--red); }
.text-primary-brand { color: var(--primary); }

.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.font-manrope { font-family: 'Manrope', sans-serif; }

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

.p-32 { padding: 32px; }
.px-32 { padding-left: 32px; padding-right: 32px; }
.py-24 { padding-top: 24px; padding-bottom: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.divider {
  height: 1px;
  background: rgba(255,255,255,0.04);
  margin: 16px 0;
}

/* Satisfaction stars */
.stars { display: flex; gap: 2px; }
.star {
  font-size: 16px;
  color: var(--surface-4);
  cursor: pointer;
  transition: color var(--transition);
}
.star.filled { color: var(--yellow); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }
.invoice-row-held::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--yellow);
  border-radius: 0 2px 2px 0;
}
.invoice-row-held td {
  opacity: 0.7;
}
/* ── TRACKER / INTELLIGENCE MODULE ── */
.tracker-live-pill{display:inline-flex;align-items:center;gap:6px;font-size:11px;font-weight:600;color:var(--green);background:var(--green-bg);border:1px solid rgba(74,222,128,0.2);border-radius:var(--radius-pill);padding:4px 10px;letter-spacing:0.04em;text-transform:uppercase;}
.tracker-live-dot{width:6px;height:6px;border-radius:50%;background:var(--green);animation:tracker-pulse 2s infinite;}
@keyframes tracker-pulse{0%,100%{opacity:1}50%{opacity:0.4}}
.tracker-stats{display:flex;background:var(--surface-2);border:1px solid var(--surface-4);border-radius:var(--radius-md);overflow:hidden;margin-bottom:20px;}
.tracker-stat{flex:1;padding:14px 18px;border-right:1px solid var(--surface-4);text-align:center;}
.tracker-stat:last-child{border-right:none;}
.tracker-stat-val{font-size:22px;font-weight:800;color:var(--text-primary);letter-spacing:-0.02em;line-height:1;}
.tracker-stat-label{font-size:11px;color:var(--text-muted);margin-top:4px;text-transform:uppercase;letter-spacing:0.06em;font-weight:600;}
.tracker-panel{padding:0;}
.tracker-columns{display:grid;grid-template-columns:1fr 280px;gap:16px;align-items:start;margin-bottom:24px;}
.tracker-feed-col{background:var(--surface-2);border:1px solid var(--surface-4);border-radius:var(--radius-md);overflow:hidden;}
.tracker-col-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid var(--surface-4);}
.tracker-col-title{font-size:13px;font-weight:600;color:var(--text-primary);}
.tracker-email-row{display:flex;align-items:center;gap:12px;padding:11px 16px;border-bottom:1px solid var(--surface-3);cursor:pointer;transition:background var(--transition);border-left:2px solid transparent;}
.tracker-email-row:last-child{border-bottom:none;}
.tracker-email-row:hover{background:var(--surface-3);}
.tracker-email-row.active{background:var(--primary-glow);border-left-color:var(--primary);}
.tracker-email-icon{width:32px;height:32px;border-radius:var(--radius-sm);display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.tracker-email-icon .material-symbols-outlined{font-size:16px;}
.icon-open{background:var(--green-bg);color:var(--green);}
.icon-sent{background:var(--surface-4);color:var(--text-muted);}
.icon-click{background:var(--yellow-bg);color:var(--yellow);}
.icon-pdf{background:var(--primary-glow);color:var(--primary);}
.tracker-email-body{flex:1;min-width:0;}
.tracker-email-subject{font-size:13px;font-weight:500;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.tracker-email-meta{font-size:11px;color:var(--text-muted);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.tracker-dot{margin:0 4px;}
.tracker-email-badges{display:flex;flex-direction:column;gap:3px;align-items:flex-end;flex-shrink:0;}
.tracker-detail-col{background:var(--surface-2);border:1px solid var(--surface-4);border-radius:var(--radius-md);min-height:200px;}
.tracker-detail-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:40px 20px;color:var(--text-muted);font-size:13px;text-align:center;}
.tracker-detail-empty .material-symbols-outlined{font-size:32px;opacity:0.4;}
.tracker-detail-card{overflow:hidden;border-radius:var(--radius-md);}
.tracker-detail-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid var(--surface-4);}
.tracker-detail-title{font-size:12px;font-weight:600;color:var(--text-secondary);text-transform:uppercase;letter-spacing:0.06em;}
.tracker-tracking-status{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--green);}
.tracker-status-dot{width:6px;height:6px;border-radius:50%;background:var(--green);}
.tracker-detail-rows{padding:4px 0;}
.tracker-detail-row{display:flex;justify-content:space-between;align-items:center;padding:8px 16px;font-size:12px;border-bottom:1px solid var(--surface-3);}
.tracker-detail-row:last-child{border-bottom:none;}
.tracker-detail-label{color:var(--text-muted);}
.tracker-detail-val{color:var(--text-primary);font-weight:500;text-align:right;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.tracker-highlight{color:var(--primary)!important;font-weight:700!important;}
.tracker-reopen-note{display:flex;align-items:center;gap:6px;padding:10px 16px;font-size:11px;color:var(--text-secondary);background:var(--primary-glow);border-top:1px solid var(--primary-border);}
.tracker-heatmap{padding:12px 16px;display:flex;flex-direction:column;gap:8px;}
.tracker-heatmap-row{display:flex;align-items:center;gap:8px;font-size:11px;}
.tracker-heatmap-pg{color:var(--text-muted);width:36px;text-align:right;flex-shrink:0;}
.tracker-heatmap-bar-wrap{flex:1;height:12px;background:var(--surface-4);border-radius:3px;overflow:hidden;}
.tracker-heatmap-bar{height:100%;background:var(--primary-dim);border-radius:3px;transition:width 0.4s ease;}
.tracker-heatmap-bar.hot{background:var(--primary);}
.tracker-heatmap-val{color:var(--text-secondary);width:30px;text-align:right;flex-shrink:0;}
.tracker-heatmap-views{color:var(--text-muted);width:20px;text-align:right;flex-shrink:0;}
.tracker-docs-section{margin-top:4px;}
.tracker-doc-grid{display:flex;flex-direction:column;gap:8px;}
.tracker-doc-card{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--surface-2);border:1px solid var(--surface-4);border-radius:var(--radius-md);cursor:pointer;transition:all var(--transition);border-left:2px solid transparent;}
.tracker-doc-card:hover{background:var(--surface-3);}
.tracker-doc-card.active{background:var(--primary-glow);border-left-color:var(--primary);}
.tracker-doc-icon{font-size:20px;color:var(--primary);flex-shrink:0;}
.tracker-doc-info{flex:1;min-width:0;}
.tracker-doc-name{font-size:13px;font-weight:500;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.tracker-doc-meta{font-size:11px;color:var(--text-muted);margin-top:2px;}
.tracker-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;padding:40px 24px;color:var(--text-muted);font-size:13px;text-align:center;}
.tracker-empty .material-symbols-outlined{font-size:36px;opacity:0.3;}
.tracker-global-list{display:flex;flex-direction:column;}
.tracker-global-row{display:grid;grid-template-columns:32px 1fr auto auto;gap:12px;align-items:center;padding:11px 20px;border-bottom:1px solid var(--surface-3);cursor:pointer;transition:background var(--transition);}
.tracker-global-row:last-child{border-bottom:none;}
.tracker-global-row:hover{background:var(--surface-2);}
.tracker-event-icon-sm{width:28px;height:28px;border-radius:var(--radius-sm);display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.tracker-event-icon-sm .material-symbols-outlined{font-size:14px;}
.tracker-global-body{display:flex;flex-direction:column;min-width:0;}
.tracker-global-who{font-size:13px;font-weight:500;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.tracker-global-subj{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px;}
.tracker-global-right{display:flex;flex-direction:column;align-items:flex-end;gap:3px;}
.tracker-global-time{font-size:11px;color:var(--text-muted);}
.tracker-global-client{font-size:11px;color:var(--primary);white-space:nowrap;}
.badge-purple{background:var(--primary-glow);color:var(--primary);border:1px solid var(--primary-border);}

/* ── MOBILE RESPONSIVE ───────────────────────────────────────── */
.mobile-header{display:none;align-items:center;gap:12px;padding:0 16px;height:52px;background:var(--surface-1);border-bottom:1px solid rgba(255,255,255,0.04);position:fixed;top:0;left:0;right:0;z-index:200}
.mobile-logo{font-size:16px;font-weight:700;color:var(--text-primary)}
.hamburger{display:flex;flex-direction:column;gap:5px;cursor:pointer;padding:6px;background:none;border:none}
.hamburger span{width:22px;height:2px;background:var(--text-primary);border-radius:2px;transition:all .3s;display:block}
.hamburger.open span:nth-child(1){transform:translateY(7px) rotate(45deg)}
.hamburger.open span:nth-child(2){opacity:0}
.hamburger.open span:nth-child(3){transform:translateY(-7px) rotate(-45deg)}
.sidebar-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:299;backdrop-filter:blur(2px)}
.sidebar-overlay.hidden{display:none}

@media(max-width:768px){
  .mobile-header{display:flex}
  .app{padding-top:52px}
  .sidebar{position:fixed;left:-260px;top:0;height:100vh;z-index:300;transition:left .3s ease;box-shadow:4px 0 24px rgba(0,0,0,0.5)}
  .sidebar.mobile-open{left:0}
  .main{width:100%;padding:0}
  .page-header{padding:16px 16px 0;flex-wrap:wrap;gap:8px}
  .page-title{font-size:20px}
  .page-actions{flex-wrap:wrap;gap:8px}
  .card{padding:16px;border-radius:10px}
  table{display:block;overflow-x:auto;-webkit-overflow-scrolling:touch}
  th,td{padding:10px 8px;font-size:12px;white-space:nowrap}
  .metrics-grid,.stats-grid{grid-template-columns:1fr 1fr}
  .form-row{flex-direction:column}
  .modal-container{width:calc(100vw - 32px);max-height:90vh;margin:16px}
  .modal-body{max-height:60vh;overflow-y:auto}
  .tabs{overflow-x:auto;flex-wrap:nowrap;-webkit-overflow-scrolling:touch}
  .tab{white-space:nowrap;flex-shrink:0}
  .client-hero{padding:16px}
  .client-meta{flex-wrap:wrap;gap:8px}
  .page-subtitle{font-size:13px}
  .btn{padding:8px 14px;font-size:13px}
  .filter-tabs{overflow-x:auto;flex-wrap:nowrap}
  .filter-tab{white-space:nowrap;flex-shrink:0}
}

@media(max-width:480px){
  .metrics-grid,.stats-grid{grid-template-columns:1fr}
  .page-actions .btn span.material-symbols-outlined + *{display:none}
  .modal-container{width:100vw;border-radius:16px 16px 0 0;position:fixed;bottom:0;left:0;right:0;margin:0}
}

/* ── MOBILE OVERFLOW FIXES ───────────────────────────────────── */
@media(max-width:768px){
  html, body { overflow-x: hidden; max-width: 100vw; }
  .app { overflow-x: hidden; max-width: 100vw; }
  .main { overflow-x: hidden; max-width: 100vw; min-width: 0 !important; }
  #view-container { overflow-x: hidden; min-width: 0 !important; max-width: 100%; }
  .card, .stat-card, .metric-card { min-width: 0 !important; max-width: 100%; }
  [style*="min-width"] { min-width: 0 !important; }
  .page-header { max-width: 100%; }
  .table-wrap, .table-container { overflow-x: auto; max-width: 100%; }
  table { min-width: 0; }
  .modal-overlay { padding: 0; }
}

/* ── MOBILE LAYOUT FIXES ─────────────────────────────────────── */
@media(max-width:768px){
  /* Dashboard stat cards - 2x2 grid */
  .stats-grid, .dashboard-stats {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  /* Finance table - hide less important columns */
  .invoices-table th:nth-child(4),
  .invoices-table td:nth-child(4) { display: none }

  /* Pipeline kanban - vertical stack */
  .pipeline-board, .kanban-board, [class*="pipeline"], [class*="kanban"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    overflow-x: hidden !important;
  }
  .pipeline-col, .kanban-col, [class*="pipeline-col"], [class*="kanban-col"] {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* ── PIPELINE + DASHBOARD MOBILE FIXES ──────────────────────── */
@media(max-width:768px){
  /* Dashboard stats 2x2 grid */
  .dashboard-grid{
    display:grid !important;
    grid-template-columns:1fr 1fr !important;
    gap:12px !important;
  }
  /* Pipeline - stack columns vertically */
  #view-container [style*="display:flex"][style*="overflow-x:auto"]{
    flex-direction:column !important;
    overflow-x:hidden !important;
    padding:0 16px 16px !important;
    gap:12px !important;
  }
  #view-container [style*="min-width:220px"]{
    min-width:0 !important;
    width:100% !important;
  }
}

/* Nav Groups */
.nav-group { margin-top: 4px; }
.nav-group-header { padding-left: 14px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  color: #6b7280; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  user-select: none; transition: color 0.15s;
}
.nav-group-header:hover { color: #9ca3af; }
.nav-group-chevron { font-size: 16px !important; transition: transform 0.2s ease; }
.nav-group.open .nav-group-chevron { transform: rotate(180deg); }
.nav-group-items { display: none; flex-direction: column; gap: 2px; padding-left: 6px; }
.nav-group.open .nav-group-items { display: flex; }
.nav-group-items .nav-item { font-size: 13px; padding: 8px 10px; }

/* btn-primary base fix */
.btn-primary {
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.15s;
  display: inline-block;
}

[id^="stab-"] { outline: none; }

/* Settings page polish */
.settings-page { padding: 32px 36px; max-width: 1100px; }
.settings-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #555; margin: 0 0 14px 0; }
.settings-card { background: #111; border: 1px solid #1f1f1f; border-radius: 12px; padding: 26px 28px; margin-bottom: 20px; }
.settings-field { margin-bottom: 14px; }
.settings-field label { display: block; font-size: 12px; color: #666; margin-bottom: 5px; font-weight: 500; }
.settings-field input, .settings-field select { width: 100%; background: #0a0a0a; border: 1px solid #242424; border-radius: 8px; padding: 9px 12px; color: #e5e5e5; font-size: 13.5px; box-sizing: border-box; }
.settings-field input:focus, .settings-field select:focus { outline: none; border-color: #7c3aed; }
.settings-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.s-divider { border: none; border-top: 1px solid #1a1a1a; margin: 20px 0; }
.team-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid #181818; }
.team-row:last-child { border-bottom: none; }
.team-row-avatar { width: 36px; height: 36px; border-radius: 50%; background: #2a1f4e; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #a78bfa; flex-shrink: 0; }
.team-row-info { flex: 1; min-width: 0; }
.team-row-name { font-size: 13.5px; font-weight: 500; color: #e5e5e5; }
.team-row-date { font-size: 11.5px; color: #444; margin-top: 2px; }
.team-row-badge { font-size: 11px; background: #1a1a2e; color: #a78bfa; border: 1px solid #2d2050; border-radius: 5px; padding: 2px 8px; font-weight: 600; }
.role-select { background: #0a0a0a; border: 1px solid #242424; border-radius: 8px; color: #ccc; padding: 7px 10px; font-size: 12.5px; }
.invite-card { background: #0f0a1e; border: 1px solid #2d2050; border-radius: 12px; padding: 20px 24px; margin-top: 4px; }
.invite-card p { font-size: 13px; color: #888; margin: 0 0 14px 0; line-height: 1.5; }
.role-list { list-style: none; padding: 0; margin: 0; }
.role-list li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid #181818; }
.role-list li:last-child { border-bottom: none; }
.role-list .ri { font-size: 15px; padding-top: 1px; }
.role-list .rn { font-size: 13px; font-weight: 600; color: #e5e5e5; margin-bottom: 2px; }
.role-list .rd { font-size: 12px; color: #555; }

/* Settings tab bar */
.stab-bar { display: flex; gap: 0; border-bottom: 1px solid #1e2536; margin-bottom: 28px; }
.stab { background: none; border: none; border-bottom: 2px solid transparent; color: #6b7280; padding: 10px 22px; font-size: 13.5px; font-weight: 500; cursor: pointer; outline: none; transition: color 0.15s, border-color 0.15s; margin-bottom: -1px; }
.stab:hover { color: #ccc; }
.stab.active { color: #fff; font-weight: 600; border-bottom: 2px solid #7c3aed; }
