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

:root {
  --bg: #080808;
  --card: #101010;
  --card-hover: #161616;
  --border: #1a1a1a;
  --border-light: #252525;
  --white: #ffffff;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #6b7280;
  --green: #25864F;
  --green-light: #2fa661;
  --green-dim: rgba(37,134,79,0.12);
  --orange: #EB8523;
  --orange-dim: rgba(235,133,35,0.12);
  --red: #DC3227;
  --red-dim: rgba(220,50,39,0.12);
  --blue: #2B378C;
  --blue-dim: rgba(43,55,140,0.15);
  --purple: #804B9B;
  --purple-dim: rgba(128,75,155,0.15);
  --lilac: #BFAAD1;
  --sidebar-w: 230px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--white);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #0a0a0a;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--white);
  display: block;
}

.logo-sub {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gray-600);
  margin-top: 3px;
  display: block;
}

.sidebar-nav {
  padding: 16px 10px;
  flex: 1;
}

.nav-section-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-600);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 0 10px;
  margin: 12px 0 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
  margin-bottom: 1px;
  cursor: pointer;
}

.nav-item:hover { background: var(--card); color: var(--gray-400); }
.nav-item.active { background: var(--green-dim); color: var(--green); }

.nav-icon {
  width: 15px; height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--gray-600);
  line-height: 1.5;
}

.live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 5px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.3; }
}

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

.topbar {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(8,8,8,0.95);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.topbar-left h1 { font-size: 16px; font-weight: 600; }
.topbar-left p { font-size: 11px; color: var(--gray-600); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content { padding: 28px 32px; flex: 1; }

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

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s;
}
.kpi-card:hover { border-color: var(--border-light); }

.kpi-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.kpi-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  font-size: 15px;
}

.kpi-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.kpi-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
}

.tag-green { background: var(--green-dim); color: var(--green); }
.tag-orange { background: var(--orange-dim); color: var(--orange); }
.tag-blue { background: var(--blue-dim); color: #6b7ff0; }
.tag-purple { background: var(--purple-dim); color: #c084d8; }

/* ── CHART CARDS ──────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-card-header h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.chart-wrap { position: relative; }

/* ── TABLE ────────────────────────────────── */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 28px;
}

.table-top {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.table-top h3 { font-size: 13px; font-weight: 600; }

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--gray-600);
  font-size: 13px;
  pointer-events: none;
}

.input {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--white);
  padding: 8px 12px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s;
}
.input-search { padding-left: 30px; width: 200px; }
.input:focus { border-color: var(--green); }
.input::placeholder { color: var(--gray-600); }

select.input { cursor: pointer; }
select.input option { background: var(--card); }

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

thead th {
  padding: 10px 18px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
  white-space: nowrap;
}

tbody td {
  padding: 13px 18px;
  font-size: 12px;
  color: var(--gray-400);
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.08s; cursor: pointer; }
tbody tr:hover td { background: var(--card-hover); color: var(--gray-200); }

td.td-name { color: var(--white); font-weight: 500; }
td.td-phone { font-family: 'Courier New', monospace; font-size: 11px; color: var(--gray-600); }
td.td-obs {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── BADGES ───────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.b-new      { background: var(--blue-dim);   color: #6b7ff0; }
.b-follow   { background: var(--orange-dim); color: var(--orange); }
.b-nseg     { background: var(--purple-dim); color: #c084d8; }
.b-payment  { background: var(--green-dim);  color: var(--green); }
.b-cerrado  { background: var(--green);      color: #fff; font-weight: 700; }
.b-default  { background: var(--border-light); color: var(--gray-600); }

.dot-row { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--green); }
.dot-orange { background: var(--orange); }
.dot-red { background: var(--red); }
.dot-gray { background: var(--gray-600); }

/* ── DETALLE ──────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-600);
  font-size: 12px;
  margin-bottom: 22px;
  transition: color 0.12s;
}
.back-link:hover { color: var(--white); }

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

.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}

.detail-card h3 {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label { font-size: 10px; color: var(--gray-600); margin-bottom: 4px; }
.field-value { font-size: 13px; color: var(--white); }

.obs-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--gray-400);
  min-height: 110px;
}

.detail-full { grid-column: 1 / -1; }

/* ── AI ANALYSIS ──────────────────────────── */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.analysis-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}

.analysis-card.full { grid-column: 1 / -1; }

.analysis-card h3 {
  font-size: 10px;
  font-weight: 600;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.analysis-text { font-size: 13px; line-height: 1.7; color: var(--gray-400); }

.quality-bars { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

.quality-bar-row { }
.quality-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray-400);
  margin-bottom: 5px;
}

.quality-bar-track {
  background: var(--border-light);
  border-radius: 100px;
  height: 6px;
  overflow: hidden;
}

.quality-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.8s ease;
}

.pattern-list { list-style: none; }
.pattern-list li {
  font-size: 12px;
  color: var(--gray-400);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}
.pattern-list li:last-child { border-bottom: none; }
.pattern-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
  margin-top: 5px;
}

.rec-list { list-style: none; counter-reset: rec; }
.rec-list li {
  font-size: 12px;
  color: var(--gray-400);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  line-height: 1.5;
  counter-increment: rec;
}
.rec-list li:last-child { border-bottom: none; }
.rec-num {
  width: 20px; height: 20px;
  background: var(--green-dim);
  color: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── BUTTONS ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.12s;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover { border-color: var(--green); color: var(--green); }

/* ── STATES ───────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--gray-600);
  font-size: 13px;
  gap: 10px;
  flex-direction: column;
}

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border-light);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 60px;
  color: var(--gray-600);
  font-size: 13px;
}

.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── PAGE TITLE REGION ───────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p { font-size: 12px; color: var(--gray-600); margin-top: 4px; }
