/* bePaid CRM — design tokens */
:root {
  --bg:         #f7f8fb;
  --surface:    #ffffff;
  --surface-2:  #f3f4f8;
  --border:     #e5e7eb;
  --border-2:   #eef0f4;
  --text:       #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;
  --primary:    #2563eb;
  --primary-d:  #1d4ed8;
  --primary-soft:#eff6ff;
  --accent:     #f43f5e;
  --success:    #10b981;
  --warn:       #f59e0b;
  --danger:     #ef4444;
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.03);
  --shadow:    0 4px 12px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --sidebar-w: 240px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================== Sidebar ===================== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex; flex-direction: column;
  padding: 18px 12px;
  z-index: 10;
}
.logo {
  display: flex; align-items: baseline; gap: 0;
  font-size: 22px; font-weight: 700; letter-spacing: -.01em;
  color: #fff; text-decoration: none;
  padding: 4px 8px 22px;
}
.logo:hover { text-decoration: none; }
.logo-mark { color: #60a5fa; }
.logo-text { color: #fff; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: #94a3b8; font-weight: 500;
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav a:hover { color: #e2e8f0; background: rgba(255,255,255,.04); text-decoration: none; }
.nav a.active { background: rgba(96,165,250,.13); color: #fff; }
.nav a svg { opacity: .75; flex-shrink: 0; }
.nav a.active svg { opacity: 1; color: #60a5fa; }

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--r);
  background: rgba(255,255,255,.04);
  margin-top: 14px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #fff; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: #94a3b8; font-size: 11.5px; }
.logout-btn { color: #94a3b8; display: flex; align-items: center; padding: 4px; border-radius: 6px; }
.logout-btn:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }

/* ===================== Main ===================== */
.main {
  margin-left: var(--sidebar-w);
  padding: 28px 36px;
  min-height: 100vh;
}
.main.no-sidebar { margin-left: 0; padding: 0; }

/* ===================== Headers ===================== */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.page-sub  { color: var(--text-2); margin-top: 4px; font-size: 13px; }

h1,h2,h3,h4 { letter-spacing: -.01em; }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: #fff; color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

/* ===================== Cards ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border-2);
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }

/* ===================== Stats grid ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  position: relative;
}
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat-meta  { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat-icon  {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}

/* ===================== Tables ===================== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.table {
  width: 100%; border-collapse: collapse;
}
.table th, .table td {
  padding: 11px 14px; text-align: left;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}
.table th {
  background: var(--surface-2);
  font-weight: 600; font-size: 12px;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom-color: var(--border);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfd; }
.table-link { color: var(--text); font-weight: 500; }
.table-link:hover { color: var(--primary); }

/* ===================== Stage badges ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: #f1f5f9; color: #475569;
  white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warn    { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* ===================== Forms ===================== */
.form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 16px 18px;
}
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #fff;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
.input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding-top: 18px; margin-top: 8px;
  border-top: 1px solid var(--border-2);
}

/* ===================== Flash ===================== */
.flash {
  padding: 10px 14px; border-radius: var(--r-sm);
  margin-bottom: 18px;
  font-size: 13px;
  background: #dbeafe; color: #1e40af;
  border-left: 3px solid #2563eb;
}
.flash-success { background: #d1fae5; color: #065f46; border-color: #10b981; }
.flash-error   { background: #fee2e2; color: #991b1b; border-color: #ef4444; }
.flash-warn    { background: #fef3c7; color: #92400e; border-color: #f59e0b; }

/* ===================== Login ===================== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 10% 20%, rgba(96,165,250,.15) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(244,63,94,.10) 0%, transparent 45%),
    #0f172a;
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 36px 36px 30px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.login-logo {
  font-size: 26px; font-weight: 700; letter-spacing: -.01em;
  text-align: center; margin-bottom: 6px;
}
.login-logo span { color: var(--primary); }
.login-sub {
  text-align: center; color: var(--text-2); font-size: 13px;
  margin-bottom: 28px;
}
.login-form .field { margin-bottom: 14px; }
.login-form .btn { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.login-hints {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border-2);
  font-size: 12px; color: var(--text-3);
}
.login-hints code {
  background: var(--surface-2);
  padding: 1px 6px; border-radius: 4px;
  color: var(--text-2);
}

/* ===================== Funnel (kanban) ===================== */
.funnel-board {
  display: flex; gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
}
.funnel-col {
  flex: 0 0 270px;
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 12px;
  max-height: calc(100vh - 180px);
  display: flex; flex-direction: column;
}
.funnel-col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 4px 10px;
  font-size: 13px; font-weight: 600;
}
.funnel-col-head .count {
  background: rgba(15,23,42,.08); color: var(--text-2);
  padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px;
}
.funnel-col-body { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.funnel-card {
  background: #fff;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--primary);
  padding: 10px 12px;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-sm);
  display: block;
}
.funnel-card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.funnel-card-title { font-weight: 600; font-size: 13px; }
.funnel-card-meta { font-size: 11.5px; color: var(--text-2); margin-top: 4px; }
.funnel-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 11px; color: var(--text-3); }

/* ===================== Client detail ===================== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
}
.detail-grid .card { margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }

.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline-item {
  display: flex; gap: 12px;
  position: relative;
}
.timeline-marker {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}
.timeline-item.note   .timeline-marker { background: #eff6ff; color: var(--primary); }
.timeline-item.call   .timeline-marker { background: #f0fdf4; color: var(--success); }
.timeline-item.stage  .timeline-marker { background: #fef3c7; color: var(--warn); }
.timeline-item.task   .timeline-marker { background: #fce7f3; color: #be185d; }
.timeline-body { flex: 1; font-size: 13px; }
.timeline-meta { color: var(--text-3); font-size: 11.5px; margin-top: 3px; }

.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  padding: 9px 14px; border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ===================== Filters bar ===================== */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 12px; border-radius: var(--r);
}
.filters .input, .filters select { max-width: 200px; }

/* ===================== Empty state ===================== */
.empty {
  text-align: center; padding: 40px 20px;
  color: var(--text-3);
}
.empty svg { opacity: .35; margin-bottom: 12px; }

/* ===================== Misc ===================== */
.muted { color: var(--text-3); }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; vertical-align: middle; margin-right: 6px; }

/* ===================== Responsive ===================== */
@media (max-width: 880px) {
  .sidebar {
    position: relative; width: 100%; height: auto; flex-direction: row;
    padding: 10px; align-items: center; gap: 10px;
  }
  .sidebar .nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .sidebar .nav a { padding: 6px 10px; font-size: 12px; }
  .user-card { margin-top: 0; padding: 6px 10px; }
  .main { margin-left: 0; padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
