/* ============================================
   CRM Pare-Brise — Premium Dark Dashboard
   Font: Syne (display) + Outfit (body)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=Outfit:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

:root {
  --bg:        #0d0f14;
  --bg2:       #13161e;
  --bg3:       #1a1e29;
  --bg4:       #21263a;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);

  --accent:    #3b82f6;
  --accent2:   #60a5fa;
  --accent-glow: rgba(59,130,246,0.2);

  --green:     #22c55e;
  --green-bg:  rgba(34,197,94,0.12);
  --green-border: rgba(34,197,94,0.25);

  --red:       #ef4444;
  --red-bg:    rgba(239,68,68,0.12);
  --red-border: rgba(239,68,68,0.25);

  --amber:     #f59e0b;
  --amber-bg:  rgba(245,158,11,0.12);
  --amber-border: rgba(245,158,11,0.25);

  --purple:    #a855f7;
  --purple-bg: rgba(168,85,247,0.12);

  --text:      #f1f5f9;
  --text2:     #94a3b8;
  --text3:     #4b5675;

  --font-display: 'Syne', sans-serif;
  --font:         'Outfit', sans-serif;

  --r:    12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --nav-w: 240px;
  --top-h: 64px;

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-accent: 0 4px 20px rgba(59,130,246,0.3);
}

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 99px; }

/* ── LAYOUT ── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--nav-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  display: flex; align-items: center; gap: 10px;
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-accent);
}
.logo-icon svg { width: 18px; height: 18px; fill: white; }
.logo-text { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--text); }
.logo-sub  { font-size: 11px; color: var(--text3); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 600;
  color: var(--text3); text-transform: uppercase; letter-spacing: 1px;
  padding: 0 8px; margin: 16px 0 6px;
}
.nav-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px;
  border-radius: var(--r);
  color: var(--text2);
  text-decoration: none;
  font-size: 14px; font-weight: 400;
  transition: all 0.15s;
  position: relative;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent2);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 99px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.15s;
}
.user-pill:hover { background: var(--bg3); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); }

/* ── MAIN ── */
.main {
  margin-left: var(--nav-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--top-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}
.topbar-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; flex: 1; }
.topbar-date  { font-size: 12px; color: var(--text3); }

.btn-new {
  display: flex; align-items: center; gap: 7px;
  background: var(--accent);
  color: white;
  border: none; border-radius: var(--r);
  padding: 9px 16px;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-accent);
  transition: all 0.15s;
  text-decoration: none;
}
.btn-new:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-new svg { width: 15px; height: 15px; }

/* ── PAGE CONTENT ── */
.page { padding: 28px; flex: 1; }

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  animation: fadeUp 0.4s ease both;
}
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }
.kpi-card:hover { border-color: var(--border2); transform: translateY(-2px); }

.kpi-card::after {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.07;
  transform: translate(20px, -20px);
}
.kpi-card.blue::after   { background: var(--accent); }
.kpi-card.green::after  { background: var(--green); }
.kpi-card.red::after    { background: var(--red); }
.kpi-card.purple::after { background: var(--purple); }

.kpi-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-icon.blue   { background: var(--accent-glow); color: var(--accent2); }
.kpi-icon.green  { background: var(--green-bg);    color: var(--green); }
.kpi-icon.red    { background: var(--red-bg);      color: var(--red); }
.kpi-icon.purple { background: var(--purple-bg);   color: var(--purple); }

.kpi-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 500; margin-bottom: 6px; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; margin-bottom: 8px; }
.kpi-trend { font-size: 12px; color: var(--text3); }
.kpi-trend span { font-weight: 500; }
.kpi-trend .up   { color: var(--green); }
.kpi-trend .down { color: var(--red); }

/* ── GRID 2 COLS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.grid-3-1 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; margin-bottom: 24px; }

/* ── CARD ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  animation: fadeUp 0.4s ease both;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.card-action { font-size: 12px; color: var(--accent2); text-decoration: none; }
.card-body { padding: 20px; }

/* ── CHART AREA ── */
.chart-wrap { position: relative; height: 220px; }

/* ── TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 11px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0 20px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text2);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg3); }
.data-table .td-primary { color: var(--text); font-weight: 500; }
.data-table .td-mono { font-family: 'Courier New', monospace; font-size: 13px; }
.data-table .td-actions { text-align: right; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 99px;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.badge.paid    { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge.paid::before { background: var(--green); }
.badge.pending { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }
.badge.pending::before { background: var(--red); }
.badge.late    { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge.late::before { background: var(--amber); }

/* ── DONUT / PROGRESS ── */
.donut-wrap {
  display: flex; align-items: center; gap: 24px;
  padding: 8px 0;
}
.donut-canvas { position: relative; flex-shrink: 0; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.legend-item  { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-label { flex: 1; color: var(--text2); }
.legend-val   { font-weight: 600; font-family: 'Courier New', monospace; font-size: 13px; }

/* ── AGENT RANKING ── */
.agent-rank-list { display: flex; flex-direction: column; gap: 0; }
.agent-rank-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.agent-rank-item:last-child { border-bottom: none; }
.agent-rank-item:hover { background: var(--bg3); }
.rank-num { font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--bg4); width: 28px; text-align: center; }
.rank-num.gold   { color: #f59e0b; }
.rank-num.silver { color: #94a3b8; }
.rank-num.bronze { color: #cd7c4a; }
.rank-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: 13px; font-weight: 500; }
.rank-sub  { font-size: 11px; color: var(--text3); }
.rank-bar-wrap { width: 80px; }
.rank-bar { height: 4px; background: var(--bg4); border-radius: 99px; overflow: hidden; }
.rank-bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 1s ease; }
.rank-total { font-size: 13px; font-weight: 600; width: 80px; text-align: right; font-family: 'Courier New', monospace; }

/* ── LATE ALERT ── */
.alert-banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(245,158,11,0.05));
  border: 1px solid var(--amber-border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
  animation: fadeUp 0.4s ease both;
}
.alert-banner svg { color: var(--amber); flex-shrink: 0; }
.alert-banner-text { flex: 1; font-size: 13px; color: var(--text2); }
.alert-banner-text strong { color: var(--amber); font-weight: 600; }
.alert-banner-btn {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
  border-radius: var(--r);
  padding: 7px 14px;
  font-family: var(--font); font-size: 12px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}

/* ── MINI STAT ROW ── */
.mini-stats { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.mini-stat {
  flex: 1; padding: 16px 20px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.mini-stat:last-child { border-right: none; }
.mini-stat-val   { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.mini-stat-label { font-size: 11px; color: var(--text3); margin-top: 3px; }

/* ── EMPTY ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text3); }
.empty-icon  { font-size: 32px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── FORMS ── */
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field       { display: flex; flex-direction: column; gap: 7px; }
.field.full  { grid-column: 1 / -1; }
.field label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field select, .field textarea {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font); font-size: 14px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.field input::placeholder, .field textarea::placeholder { color: var(--text3); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field select option { background: var(--bg3); }
.field textarea { resize: none; height: 90px; line-height: 1.6; }
.req { color: var(--red); }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--border); }
.btn-primary {
  background: var(--accent); color: white;
  border: none; border-radius: var(--r);
  padding: 11px 22px;
  font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary.green { background: var(--green); box-shadow: 0 4px 14px rgba(34,197,94,0.3); }
.btn-secondary {
  background: var(--bg4); color: var(--text2);
  border: 1px solid var(--border2); border-radius: var(--r);
  padding: 11px 22px;
  font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg3); color: var(--text); }
.btn-danger {
  background: var(--red-bg); color: var(--red);
  border: 1px solid var(--red-border); border-radius: var(--r);
  padding: 11px 22px;
  font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
}

/* ── SEARCH BAR ── */
.search-topbar { display: flex; gap: 12px; margin-bottom: 20px; }
.search-wrap { position: relative; flex: 1; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; width: 15px; height: 15px; }
.search-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font); font-size: 14px;
  padding: 10px 14px 10px 38px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text3); }

.filter-chips { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.chip {
  font-family: var(--font); font-size: 12px; font-weight: 500;
  padding: 6px 14px; border-radius: 99px;
  border: 1px solid var(--border2);
  background: var(--bg2); color: var(--text2);
  cursor: pointer; text-decoration: none;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent2); }
.chip.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }

/* ── FAB ── */
.fab {
  position: fixed; bottom: 28px; right: 28px;
  width: 52px; height: 52px;
  background: var(--accent);
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 200;
  box-shadow: var(--shadow-accent);
  transition: all 0.2s;
}
.fab:hover { transform: scale(1.08); background: var(--accent2); }

/* ── AUTH ── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  position: relative; overflow: hidden;
}
.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(59,130,246,0.08) 0%, transparent 70%);
  top: -200px; left: 50%; transform: translateX(-50%);
  pointer-events: none;
}
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  position: relative; z-index: 1;
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo-icon {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  box-shadow: var(--shadow-accent);
}
.auth-logo-icon svg { width: 26px; height: 26px; fill: white; }
.auth-logo h1 { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.auth-logo p  { font-size: 13px; color: var(--text3); margin-top: 4px; }
.auth-form    { display: flex; flex-direction: column; gap: 16px; }

/* ── DETAIL PAGE ── */
.detail-hero {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px 32px;
  margin-bottom: 20px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
}
.detail-amount-big { font-family: var(--font-display); font-size: 44px; font-weight: 800; line-height: 1; margin-bottom: 12px; }
.detail-num { font-size: 12px; color: var(--text3); margin-bottom: 16px; }
.detail-actions { display: flex; gap: 10px; flex-shrink: 0; }

.detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.info-list   { display: flex; flex-direction: column; gap: 0; }
.info-row    { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-key    { color: var(--text3); }
.info-val    { font-weight: 500; text-align: right; }
.info-val.green  { color: var(--green); }
.info-val.blue   { color: var(--accent2); }

/* ── ALERTS ── */
.alert { padding: 12px 16px; border-radius: var(--r); font-size: 13px; margin-bottom: 16px; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.alert-danger  { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }

/* ── BACK LINK ── */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text3);
  text-decoration: none; margin-bottom: 20px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

/* ── FILE UPLOAD ── */
.file-upload {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--border2);
  border-radius: var(--r);
  cursor: pointer; color: var(--text3); font-size: 13px;
  transition: border-color 0.15s;
}
.file-upload:hover { border-color: var(--accent); color: var(--accent2); }
.file-upload input { display: none; }

/* ── MOBILE TOGGLE ── */
.menu-toggle {
  display: none;
  background: transparent; border: none;
  color: var(--text); cursor: pointer; padding: 6px;
}

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}
@media (max-width: 768px) {
  :root { --nav-w: 0px; }
  .sidebar {
    transform: translateX(-240px);
    width: 240px;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .page { padding: 16px; }
  .topbar { padding: 0 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 20px; }
  .fab { bottom: 16px; right: 16px; }
  .detail-hero { flex-direction: column; }
  .detail-amount-big { font-size: 32px; }
}
