/* ============================================================
   CRM - Design System
   ============================================================ */
:root {
  --primary:       #005496;
  --primary-dark:  #003d6b;
  --accent:        #0078d4;
  --bg:            #f0f3f8;
  --card:          #ffffff;
  --border:        #dde3ed;
  --text:          #1e1e1e;
  --text-muted:    #6b7280;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --sidebar-w:     240px;
  --header-h:      56px;
  --radius:        8px;
  --shadow:        0 1px 4px rgba(0,0,0,.10);
  --shadow-md:     0 4px 16px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; background: var(--bg); color: var(--text); display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w); background: var(--primary-dark); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
  transition: width .2s;
}
.sidebar-logo {
  padding: 20px 16px 16px; font-size: 18px; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.1); letter-spacing: .5px;
}
.sidebar-logo span { color: #60b0ff; }
nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; color: rgba(255,255,255,.85); text-decoration: none;
  border-left: 3px solid transparent; font-size: 13.5px; transition: all .15s;
}
nav a:hover  { background: rgba(255,255,255,.08); color: #fff; }
nav a.active { background: rgba(255,255,255,.13); color: #fff; border-left-color: #60b0ff; font-weight: 600; }
nav a .icon  { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-section { padding: 12px 16px 4px; font-size: 10px; text-transform: uppercase; color: rgba(255,255,255,.4); letter-spacing: 1px; }

/* ── Main ── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Header ── */
#header {
  height: var(--header-h); background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0;
  box-shadow: var(--shadow);
}
#header h1 { font-size: 16px; font-weight: 600; flex: 1; }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 7px 16px; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary:hover { background: var(--primary); }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); padding: 7px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Content ── */
#content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── KPI Cards ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border-left: 4px solid var(--accent); }
.kpi-card .label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .5px; margin-bottom: 6px; }
.kpi-card .value { font-size: 24px; font-weight: 700; color: var(--primary); }
.kpi-card .sub   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.kpi-card.success { border-left-color: var(--success); }
.kpi-card.warning { border-left-color: var(--warning); }
.kpi-card.danger  { border-left-color: var(--danger); }

/* ── Cards / Panels ── */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--primary); color: #fff; padding: 10px 14px; text-align: left; font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; cursor: pointer; }
tbody tr:hover { background: #eef4fd; }
tbody td { padding: 9px 14px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-green   { background: #dcfce7; color: #16a34a; }
.badge-yellow  { background: #fef9c3; color: #a16207; }
.badge-red     { background: #fee2e2; color: #dc2626; }
.badge-gray    { background: #f3f4f6; color: #6b7280; }
.badge-purple  { background: #ede9fe; color: #7c3aed; }
.badge-orange  { background: #ffedd5; color: #c2410c; }

/* ── Pipeline ── */
.pipeline { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.pipeline-col { min-width: 220px; background: #f3f6fb; border-radius: var(--radius); padding: 12px; flex-shrink: 0; }
.pipeline-col h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 10px; }
.pipeline-col .count { font-size: 11px; color: var(--text-muted); }
.oport-card { background: var(--card); border-radius: 6px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); border-left: 3px solid var(--accent); cursor: pointer; }
.oport-card:hover { box-shadow: var(--shadow-md); }
.oport-card .titulo { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.oport-card .cliente { font-size: 11px; color: var(--text-muted); }
.oport-card .importe { font-size: 13px; font-weight: 700; color: var(--primary); margin-top: 6px; }
.oport-card .prob { font-size: 11px; color: var(--text-muted); }

/* ── Kanban Leads ── */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { min-width: 200px; background: #f3f6fb; border-radius: var(--radius); padding: 12px; flex-shrink: 0; }
.kanban-col h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.lead-card { background: var(--card); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; border-top: 3px solid var(--accent); }
.lead-card:hover { box-shadow: var(--shadow-md); }
.lead-card .nombre { font-weight: 600; font-size: 13px; }
.lead-card .empresa { font-size: 11px; color: var(--text-muted); }
.lead-card .origen  { font-size: 10px; margin-top: 4px; }

/* ── Agenda/Calendar ── */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.cal-day-name { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 4px; }
.cal-day { min-height: 80px; background: var(--card); border-radius: 4px; padding: 4px; border: 1px solid var(--border); }
.cal-day.today { border-color: var(--accent); }
.cal-day.other-month { background: #f8f9fb; opacity: .6; }
.cal-day-num { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.cal-event { font-size: 10px; background: var(--accent); color: #fff; border-radius: 3px; padding: 1px 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-event.visita   { background: #7c3aed; }
.cal-event.llamada  { background: #16a34a; }
.cal-event.reunion  { background: #d97706; }
.cal-event.tarea    { background: #0078d4; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--card); border-radius: var(--radius); width: 560px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Form ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row  { display: flex; flex-direction: column; gap: 4px; }
.form-row.full { grid-column: 1/-1; }
label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
input, select, textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; transition: border .15s; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }

/* ── Search bar ── */
.search-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.search-bar input { flex: 1; max-width: 320px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Progres bar ── */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1e293b; color: #fff; padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow-md); font-size: 13px; z-index: 2000; opacity: 0; transform: translateY(10px); transition: all .25s; }
.toast.show { opacity: 1; transform: none; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }

/* ── Empty state ── */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty .icon { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c9d4; border-radius: 3px; }
